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.
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).
--
- Warp
Post a reply to this message
|