Subject: Re: [boost] [smart_ptr] copyable_ptr?
From: Thomas Klimpel (Thomas.Klimpel_at_[hidden])
Date: 2009-07-17 04:51:23
Mathias Gaunard wrote:
>Gottlob Frege wrote:
>> On Thu, Jul 16, 2009 at 4:46 PM, Ross Levine<ross.levine_at_[hidden]> wrote:
>>> I was wondering if boost has considered a smart pointer that is similar to
>>> scoped_ptr but supports deep copy semantics. This would be useful in classes
>>> which use the pimpl idiom, as a common way to program these classes is with
>>> a scoped_ptr or auto_ptr, but then a copy constructor and copy assignment
>>> operator needs to be defined. Herb Sutter worked on an implementation at
>>> http://www.gotw.ca/gotw/062.htm, so there's precedent. Is there any interest
>>> for this?
>> You might want to consider copy on write.
>Copy on write is nothing more than a possible implementation for the
>utility he's requesting, and arguably a pretty bad one (it's only useful
>in the absence of move semantics).
I have the impression that the copy_on_write will not work well together with serialization, but I haven't tried. By this statement I mean that objects that were shared before serialization (saving) "should" also be shared after deserialization (loading). So I have the impression that shared_ptr has a definitive advantage over copy_on_write here.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk