Talk:More C++ Idioms/Copy-on-write

Note that the non const operator*/operator-> is not really safe:

See: http://www.gotw.ca/gotw/044.htm for solution, basically we need to introduce a new Unsharable state.


 * I think I added something along these lines, maybe a bit more convoluted, based on the book.
 * I could not find a CowPtr facility in Boost, which seems odd. Does anyone know why? Thanks. 123.225.75.106 (talk) 03:53, 23 April 2009 (UTC)

Note, the implementation on this wiki page lacks a destructor and does not trat cloning of polymorph pointees correctly. This can be doen at the cost of a larger state (add 1 attribute) and using a templated constructor, which sets up the cloner/deleters.


 * The default compiler-supplied destructor will do the right thing...

std::shared_ptr
With C++11, Boost is not required:


 * 1) include

...

typedef std::shared_ptr RefPtr;