Boost logo

Boost :

Subject: Re: [boost] Generic copy-on-write infrastructure in boost?
From: Jason Dictos (jdictos_at_[hidden])
Date: 2009-08-13 11:01:24

Essentially what we want to do is have a heap ptr class that can be copied around easily, without incurring the continual cost of duplicating the heap space on each copy operation.

So we could for instance return this class directly on the stack from a method, and it would not consume additional heap ptrs, as the data would not have changed between each copy constructor, merely a reference count would be toggled a bit.

Really almost exactly like an STL string (Assuming COW was being used of course), except it would hold binary safe data.


-----Original Message-----
From: boost-bounces_at_[hidden] [mailto:boost-bounces_at_[hidden]] On Behalf Of Edouard A.
Sent: Thursday, August 13, 2009 1:50 AM
To: boost_at_[hidden]
Subject: Re: [boost] Generic copy-on-write infrastructure in boost?

On Wed, 12 Aug 2009 18:09:39 -0700, Jason Dictos <jdictos_at_[hidden]>

> I'm looking for a way to implement a project using some
> copy-on-write feature, similar to how STL strings use
> reference counters to prevent needles copying of data. Is
> there anything in boost to help me out with this?

If I understand correctly, what you need is something that passes the
pointer along of the object, and when a non const operation is performed on
the object, a "clone" like method is called?

I guess you could rework shared_ptr, and have a .get() const and a .get()
non const. When the refcount is 1, .get() does not clone.

Is that what you need?

ps : I'm curious, why do you need copy on write?

Unsubscribe & other changes:
Check out the Barracuda Spam & Virus Firewall - offering the fastest
virus & malware protection in the industry:

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