Boost logo

Boost :

Subject: Re: [boost] copy on write for std containers
From: Jeffrey Lee Hellrung, Jr. (jhellrung_at_[hidden])
Date: 2010-12-04 20:11:19


On 12/4/2010 4:33 PM, Peter Foelsche wrote:
> "Jeffrey Lee Hellrung, Jr." <jhellrung_at_[hidden]> wrote in message
> news:4CFADA65.40708_at_ucla.edu...
>> I think the point is that copy-on-write is rarely optimal, often
>> suboptimal, and increases complexity; hence it should not be encouraged.
>
> increases complexity -- wrong -- I only replaced the matching types --
> the using code was not modified.
> The number of lines for the wrapper are minimal -- I only implemented
> the methods I'm using.
> I don't care about complexity the compiler has to manage.
> I care about the complexity I have to manage.
> I could introduce some filtering to avoid storing identical instances
> which would even more decrease the memory foot print.

Rather than address these points directly, I will simply refer to Herb
Sutter's discussions [1,2,3,4] on copy-on-write. I'm not claiming that
copy-on-write is never a good solution, only that it should not be one's
knee-jerk reaction (to say the least) to reducing unnecessary copies.
There are solutions that, much more often than not, are superior that
one should explore first, especially now with emulated move semantics or
true move semantics.

[1] http://www.gotw.ca/gotw/043.htm
[2] http://www.gotw.ca/gotw/044.htm
[3] http://www.gotw.ca/gotw/045.htm
[4] http://www.gotw.ca/publications/optimizations.htm

- Jeff


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk