|
![](/i/fill.gif) |
Am 07.06.2012 16:35, schrieb Warp:
> clipka<ano### [at] anonymous org> wrote:
>> The only caveat not explicitly warned about in the smart pointers
>> documentation is that the smart pointer assignment operator ("=") is
>> implemented as a swap operation, so to create another smart pointer
>> referencing the same object you need to explicitly make use of the smart
>> pointers' copy constructor:
>
> That makes no sense. It would break basically everything if it were like
> that.
That's what I thought when I first saw it (or, rather, imagined to see it).
> You are confusing it with how operator= of some versions of shared_ptr might
> be implemented, in that it internally swaps its contents with a temporary
> that has been initialized with the parameter (this is done to avoid problems
> that would happen when assigning to itself). Externally there's no swapping
> behavior (and there can't be).
Hm... I just re-read the boost shared_ptr assignment specs, and you're
obviously right. How I read that misconception into the docs I have no
idea (it's been unchanged for ages), but for obvious reasons it stuck.
I guess I'm just having a bit of cleanup work in the POV-Ray code cut
out for me...
Post a reply to this message
|
![](/i/fill.gif) |