Boost logo

Boost :

Subject: Re: [boost] copy on write for std containers
From: Ulrich Eckhardt (doomster_at_[hidden])
Date: 2010-12-08 14:13:38

On Saturday 04 December 2010 20:46:49 Peter Foelsche wrote:
> I wrote a couple of lines and replaced std::set and std::map with some
> copy-on-write-wrappers and I got a dramatic speed improvement with the
> last gcc 4.5. I think.
> My code was using recursive functions iterating over a tree returning and
> setting such objects.
> I looked and it seems there is nothing like this in boost!

Automatic COW is often generating too much overhead. Using objects you only
explicitly clone when you need a modifyable copy can be beneficial though, and
there is a very simple way to achieve both: Use a shared_ptr<T const> for the
shared, immutable object and an auto_ptr<T> for the unshared, mutable one.


Boost list run by bdawes at, gregod at, cpdaniel at, john at