Please consider using the Flyweight pattern implementation, which was shortly accepted into the boost.

The implementation can be found here:
http://www.boostpro.com/vault/index.php?direction=0&order=&directory=Patterns

As I see it, you can use this implementation to easily implement copy-on-write job for you.

With Kind Regards,
Ovanes



On Wed, Jul 16, 2008 at 7:33 PM, Michiel Helvensteijn <m.helvensteijn@gmail.com> wrote:
I am looking for a simple way to implement copy-on-write classes.

Several `copies' of an instantiation of such a class can coexist and share
the same data in memory until someone changes their `copy' (calls a
non-const member function). At that time, a deep copy is made and the
change is only made in that one location. The deep copy is not needed, of
course, if the instantiation has only one handle. All of this should be
transparent to the user of the class.