Subject: Re: [boost] [smart ptr] Any interest in copy-on-write pointer forC++11?
From: Peter Dimov (lists_at_[hidden])
Date: 2013-02-11 12:55:44
Jeffrey Lee Hellrung, Jr. wrote:
> +1 for explicit copy-on-write. At that point, you're basically just
> with something close to an augmented shared_ptr< T const >.
With explicit write(), one could envisage a family of two pointers, one the
equivalent of shared_ptr<T const>, the other, returned from write, an
equivalent of unique_ptr<T> to the only mutable copy so far. Once you're
done writing, you would move it into a read_ptr again.
That interface might not prove very convenient in practice though. Although
you could, I think, build apply/APPLY upon it.
if( write_ptr<T> pw = pr.write() )
pr = std::move( pw );
I don't, however, particularly like the semantics of the case in which pr is
already unique. In principle it shouldn't matter because we're writing pr
from this thread, so nobody ought to be reading it, but still, it doesn't
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk