Boost logo

Boost :

Subject: Re: [boost] [move][container] Review Request (new versions of Boost.Move and Boost.Container in sandbox and vault)
From: Christopher Jefferson (chris_at_[hidden])
Date: 2009-09-07 15:26:09


On 7 Sep 2009, at 20:08, Jeffrey Hellrung wrote:

> Howard Hinnant wrote:
>> Using an experimental C++0x compiler and library (you might can do
>> this experiment g++-4.4, I'm not sure) I make this substitution and
>> indeed, I get the same output (remove all of the *.dat files prior
>> to each run). This experimental library has:
>> template <class _Tp, class _Allocator>
>> inline
>> vector<_Tp, _Allocator>&
>> vector<_Tp, _Allocator>::operator=(vector&& __x)
>> {
>> clear();
>> swap(__x);
>> return *this;
>> }
>
> Perhaps a dumb question, but isn't the above incorrect under self-
> assigment (x = move(x))? Is there a "standard way" or "recommended
> guideline" for handling self-assignment in the move assignment
> operator, or is this a nonissue?

I'm actually not 100% positive what the intended semantics of x = move
(x) are, but clearly as a QOI issue it should behave.

Most people put:

if(&__x != this)

or something similar in normal assignment operators, adding it also to
all move operators seems very sensible.

Chris


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