|
Boost : |
Subject: Re: [boost] [move][container] Review Request (new versions ofBoost.Move and Boost.Container in sandbox and vault)
From: David Abrahams (dave_at_[hidden])
Date: 2009-09-07 18:03:12
on Mon Sep 07 2009, "Peter Dimov" <pdimov-AT-pdimov.com> wrote:
>> Rationale:
>> The move assignment operator should be fast enough that an extra if-
>> test may adversely impact performance (above the noise level).
>
> The problem with making it UB is that y = move(x) now needs to be guarded with if( &x
> != &y ) everywhere in client code. Sometimes the user will know that x is not y, but
> is this really the case most of the time?
Most of the time, yeah. Definitely, in most of the generic algorithms.
But I'm not sure whether it's true enough of the time. Consider our new
generic std::swap:
template <class T>
void swap(T& x, T& y)
{
T z = std::move(x);
x = std::move(y); // <== uh oh?
y = std::move(z);
}
Do we think swap(x,y) is also an error when x == y?
-- 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