Boost logo

Boost :

Subject: Re: [boost] [utility] new auto_buffer class --- RFC
From: David Abrahams (dave_at_[hidden])
Date: 2009-03-18 07:54:17


on Sat Mar 14 2009, Thorsten Ottosen <thorsten.ottosen-AT-dezide.com> wrote:

> David Abrahams skrev:
>>
>> A class that attempts to provide value semantics but doesn't support x = x is
>> putting a big hole in the system of equational reasoning. Justifying that (to me)
>> would take some pretty heavy proof.
>
> I have not really seen code that exhibits x = x. I've seen lot's of discussion
> (e.g. Sutter & Meyers). Does anybody write such code?

Yes, it happens. It doesn't happen that way, of course. It happens in
x = y when x and y happen to refer to the same object.

Regardless, as I've been saying, the burden of proof runs in the other
direction. You need to show a /realistic/ benchmark that suffers
significantly. And don't bias the test unfairly, either: you only need
the self-assignment check in your slow branch, the one that does the
allocation.

The great computer scientists that came before us have shown us the way.
http://en.wikipedia.org/wiki/Optimization_(computer_science)#When_to_optimize

-- 
Dave Abrahams
BoostPro Computing
http://www.boostpro.com

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