superfluous constructor ?
Jonathan Wakely
jwakely.gcc@gmail.com
Sun Feb 26 15:39:00 GMT 2012
On 26 February 2012 15:38, Jonathan Wakely wrote:
> On 26 February 2012 12:29, Jonathan Wakely wrote:
>> On 26 February 2012 03:21, Serge Pavlovsky wrote:
>>> hi
>>> in <functional>
>>> function&
>>> operator=(function&& __x)
>>> {
>>> function(std::move(__x)).swap(*this);
>>> return *this;
>>> }
>>> why not just __x.swap(*this); ?
>>>
>>
>> That would not destroy the current contents of *this immediately.
>
> See http://cplusplus.github.com/LWG/lwg-closed.html#675 and
Sorry, that first link should be
http://cplusplus.github.com/LWG/lwg-defects.html#675
> http://cplusplus.github.com/LWG/lwg-closed.html#910 for discussion
> regarding this point. The target of a move operation is expected to
> be "cleared" so that destructors don't run late.
More information about the Libstdc++
mailing list