
On 5/19/06, Pavel Vozenilek <pavel_vozenilek@hotmail.com> wrote:
If a read-write lock will be added it should be optional - the overhead may be too big.
It should be also possible to _manually_ trigger the cloning:
The Adobe Open Source libraries have a copy_on_write<T> that implements this nicely. There is a method called write() which triggers the copy operation and returns a ref to the newly cloned object. The copy is only performed if there is more than one reference to the object. adobe::copy_on_write<int> first (42); adobe::copy_on_write<int> second (first); assert (first.identity (second)); // same object first.write() = 56; // a copy is made, and a ref to it is returned assert (!first.identity(second)); assert (first.unique_instance()); assert (second.unique_instance()); first.write() = 42; // no copy, since first is a unique instance http://opensource.adobe.com/classadobe_1_1copy__on__write.html -- Caleb Epstein caleb dot epstein at gmail dot com