Boost logo

Boost :

From: David B. Held (dheld_at_[hidden])
Date: 2005-03-03 19:30:59

Pavel Chikulaev wrote:
> Do you know that well-known Herb Sutter's assignment operator in most
> cases does unnecessary copying?

I don't know that it's "Herb's" assignment operator. He certainly
popularized the idiom with his book, but it may have existed before

> [...]
> Matrix func ();
> Matrix a;
> //...
> Matrix = func();
> Result of func() is copied to temporary objectand then operator = copies it
> again. So assigning to result of function creates one useless object.
> [...]

I would like to see compiler tests that show that neither RVO nor NRVO
work in these cases first.


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