Boost logo

Boost :

Subject: Re: [boost] Improving the assignment operators of various Boosttypes
From: Thorsten Ottosen (thorsten.ottosen_at_[hidden])
Date: 2008-09-11 05:06:47

Gevorg Voskanyan skrev:
> Giovanni Piero Deretta wrote:
>> If you do not want to deal with move emulation (which I've found very
>> brittle in complex expressions), a simple way to to gain the advantage
>> of T::operator=(T rhs) even when assigning from lvalues is something
>> like:
>> templateT destructive_copy(T& x) {
>> using std::swap;
>> T result;
>> swap(result, x);
>> return x;
>> }
>> which relies on NRVO to eliminate expensive copies:

I think the best way (= most RVOs) to write the assignment operator is
to take the T argument by value.


Boost list run by bdawes at, gregod at, cpdaniel at, john at