
7 Sep
2009
7 Sep
'09
9:31 p.m.
I wrote:
T& operator=( T&& x ) { T( move(x) ).swap( *this ); return *this; }
This is the generic version, but for vector, one might also consider the equivalent of T& operator=( T&& x ) { T tmp( move(x) ); clear(); swap( x ); swap( tmp ); return *this; } to avoid deallocating the current capacity of *this.