
On Tue, 15 Feb 2005 18:02:57 -0200 Bruno MartÃnez Aguerre <br1@internet.com.uy> wrote:
Why not:
optional& operator=(optional rhs) { optional_swap(*this, rhs); return *this; } ?
That is a very valid option as well. In fact, in his book, Sutter mentions that option specifically... Exceptional C++, page 48: "If you're one of those folks who like terse code, you can write the operator=() canonical form more compactly as: Stack& operator=(Stack other) { Swap( other ); return *this; } " Not being very up to date on optimization techniques, I do not know if a compiler can turn one into better code than the other. Barring that, I prefer the less-terse one, because I also prefer passing ref-to-const over by-value, unless there is a good reason to do otherwise.