• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: gcc and a problem with temporaries
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: gcc and a problem with temporaries


  • Subject: Re: gcc and a problem with temporaries
  • From: Steve Sisak <email@hidden>
  • Date: Wed, 30 Apr 2008 17:12:06 -0400

At 3:51 PM -0500 4/30/08, Scott Thompson wrote:
While adding that that makes sense for this toy example, it doesn't work in the original code where "Inited" is a "smart pointer" object. The "itemToCopy" is expected to relinquish control of the pointer it contains to the newly initialized object and is, therefore, not const in this context.

Just thinking off the top of my head, this may be a case for "conceptual constness" where it's OK to declare a method const then do a const_cast<> in the implementation to modify object state anyway.


i.e. the fact that this internal state is modified is an implementation detail of an method that is externally declared to be cost.

IIRC, you have to do this with smart pointers to get the right semantics.

(I think there's a chapter in one of the Scott Meyers books on this)

HTH,

-Steve
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: gcc and a problem with temporaries
      • From: Ken Thomases <email@hidden>
References: 
 >gcc and a problem with temporaries (From: Scott Thompson <email@hidden>)

  • Prev by Date: Re: Xcode 3.1(Beta) Developer Documentation opens in separate Safari window
  • Next by Date: Re: gcc and a problem with temporaries
  • Previous by thread: gcc and a problem with temporaries
  • Next by thread: Re: gcc and a problem with temporaries
  • Index(es):
    • Date
    • Thread