Discussion
Prefer to declare copy assignment for a type T with one of the following signatures (see [Stroustrup00] and [Alexandrescu03a]):T& operator=( const T& ); // classic
T& operator=( T ); // potentially optimizer-friendly (see Item 27)
Settle for the second version if you would need to make a copy of the argument inside your operator anyway, such as the swap -based idiom featured in Item 56.Meyers96] §33 and [Sutter04] §19). If you think you need virtual behavior for assignment, reread those citations first. If that doesn't dissuade you and you still think you need virtual assignment, prefer to provide a named function instead (e.g., virtual void Assign( const T& ); ).Item 71.)Item 56), it will automatically be both strongly error-safe and safe for self-assignment; if self-assignment is frequent due to reference aliasing or other reasons, it's okay to still check for self-assignment anyway as an optimization check to avoid needless work.Meyers97] §16); note that swapping automatically take cares of all these things. Return *this ([Meyers97] §15).