Subject: Re: [boost] [smart ptr] Any interest in copy-on-write pointer for C++11?
From: Vicente J. Botet Escriba (vicente.botet_at_[hidden])
Date: 2013-02-10 04:27:53
Le 10/02/13 03:04, Vicente J. Botet Escriba a écrit :
> Le 08/02/13 16:16, Ralph Tandetzky a écrit :
>> is there any interest in a copy-on-write pointer implementation? I
>> wrote a cow_ptr<T> template class for C++11 which has the following
>> use cases:
> As others I would prefer another name for the class. Could you compare
> how you class relates to value_ptr as defined here
I meant " N3339: A Preliminary Proposal for a Deep-Copying Smart
>> 3. You can add cloning to a class hierarchy from the outside. With
>> cow_ptr<Base> a( new Derived1 );
>> cow_ptr<Base> b( new Derived2 );
>> cow_ptr<Base> c;
>> c = a; // performs a shallow copy.
>> c->doSomething(); // makes a deep copy of a as a Derived1
>> // There is no slicing involved.
>> you copy Base objects polymorphically. The class Base can even be
>> abstract here. It is only required that Derived1 and Derived2 be
> It seems to me that the copy of polymorphic object works only with the
> help of the user and that the following should be mentioned as a
> Base* ba = new Derived1;
> cow_ptr<Base> a( ba );
> cow_ptr<Base> c;
> c = a; // performs a shallow copy.
> c->doSomething(); // couldn't makes a deep copy of a as a
> Derived1 class as the type has been lost.
> // There is a slicing involved.
If this is confirmed, I see it as a show-stopper, and the cloning
strategy must be redefined.
I don't see any relational operators. Is this intentional?
It is worth adding interactions with nullptr_t?
What about a T* release() member function?
What about a reset(U*) member function ?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk