Boost logo

Boost Users :

From: Michiel Helvensteijn (m.helvensteijn_at_[hidden])
Date: 2008-07-16 13:33:41


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.

I think implementing such a class would be easier with a special class to
inherit from and/or a useful set of macro's designed for this purpose.

This seems like something that would (or should) exist in boost. Does boost
provide something like this?

If not, I will write it myself. But I'm still not sure how to approach it. I
imagine shared_ptr would play a role, though. Any ideas?

-- 
Michiel Helvensteijn

Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net