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" <rabartl-AT-sandia.gov> wrote:
> 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
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*
-- Dave Abrahams BoostPro Computing http://boostpro.com