Subject: Re: [boost] [smart ptr] Any interest in copy-on-write pointerforC++11?
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2013-02-11 17:23:54
On Mon, Feb 11, 2013 at 1:52 PM, Peter Dimov <lists_at_[hidden]> wrote:
> Jeffrey Lee Hellrung, Jr. wrote:
> On Mon, Feb 11, 2013 at 12:01 PM, Ralph Tandetzky <
> ralph.tandetzky_at_[hidden]**> wrote:
> > Nice idea though. write_ptr<T> would behave like value_ptr<T>
>> Not as I understand it; write_ptr would behave similar to unique_ptr,
>> it would be move-only.
> You could, in principle, make it do a deep copy, but the point of the
> exercise is to avoid inadvertent expensive copies, so a move-only pointer
> makes a bit more sense, I think.
An explicit copy() could perform the deep copy, if needed. On the other
> hand, making it do a deep copy is slightly more flexible because you could
> then use it as a value_ptr if you don't care for the whole CoW business. I
> could go either way on that.
I'm not sure what you mean by "not caring for the whole CoW business". If
you mean you want shared mutable objects and don't care whether the
mutations are shared, then why wouldn't you just use std::shared_ptr? If
you actually want a copy, just make a copy or clone or whatever, seems
orthogonal to sharing and mutating to me. Or maybe I'm misunderstanding you.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk