Re: gcc and a problem with temporaries
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