
On 10/02/13 10:27, Vicente J. Botet Escriba wrote:
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 limitation
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.
This is something that I already pointed out elsewhere on the thread. To me the best approach is to make the class have a "virtual copy constructor" (a clone virtual member function counts as one), which is the only way to fix this issue. I don't quite like the approach in N3339 because it couples allocation and copy construction.