
9 Sep
2008
9 Sep
'08
11 p.m.
Niels Dekker:
Basically it was concluded that /if/ an assignment operator is implemented by means of copy-and-swap, it should preferably be done as follows:
T& operator=(T arg) { arg.swap(*this); return *this; }
This is well known (although the typical form is swap(arg) instead of arg.swap(*this)). It is not widely used in Boost because it creates problems with some compilers (I recall Borland being one). The "classic" form is, unsurprisingly, much better supported across the board. Things may have improved now, of course.