Boost logo

Boost :

Subject: Re: [boost] Temporary objects
From: DE (satan66613_at_[hidden])
Date: 2009-11-02 12:38:09

on 31.10.2009 at 18:37
 Thomas Klimpel wrote :
> What I'm talking about is that the
> move-assignment operator of the proposed boost::container::vector is implemented for good reasons as

> vector& operator=(BOOST_RV_REF(vector) x)
> {
> if (&x != this){
> this->swap(x);
> x.clear();
> }
> return *this;
> }

> and it would be nice if it would be allowed to implement it as

> vector& operator=(BOOST_RV_REF(vector) x)
> {
> this->swap(x);
> return *this;
> }

> However, I accepted that "it would be nice" won't come reality,
> because the good reasons are just too good (with the otherwise
> required language change as final word).
good point, i second this
i think there is no need for self-assignment test
rather assignment (or whatever) should be implemented in a
self-assignment-safe manner
also there is no need to 'clear()' because the destructor will take care
of whatever the object 'x' remains to be
and finally i think that 'this->swap(x)' and 'x.swap(*this)' must have
identical by definition effect so there is no matter what form to use


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