Boost logo

Boost :

Subject: Re: [boost] Review of a safer memory management approach for C++?
From: David Abrahams (dave_at_[hidden])
Date: 2010-06-05 09:56:38

on Fri Jun 04 2010, "Bartlett, Roscoe A" <> wrote:

> David,
> From: David Abrahams [mailto:dave_at_[hidden]]
>> The whole notion of deep-vs-shallow copy is a fallacy. If you nail
>> down what it means to make a “copy”---which will force you to nail
>> down what constitutes an object's value---you'll see that.
> [Bartlett, Roscoe A]
> It is not a fallacy. The only obvious behavior for value semantics is deep copy such
> that if you do:
> A a(...);
> B b = a;
> then any change to 'b' will have *no* impact on the behavior of 'a' at
> all, period.

And that, right there, is the definition of “copy” (assuming A and B are
the same type). There's no such thing as a “shallow copy” of a that's
different from what you just described.

> Anything else is not value semantics and will confuse people. Make it simple; most
> types should have either value semantics or reference semantics as described in
> Section 4.1 in the Teuchos MM report. Anything in between is just confusing and
> counter-intuitive.

Your “reference types” as defined there are not copyable, so there's no
“shallow copy” going on. Period. Viewing it that way makes it *really*
simple. :-)


Dave Abrahams
BoostPro Computing

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