October 2004
Intermediate to advanced
240 pages
6h 22m
English
Your assignment: When implementing operator=, prefer the canonical form—nonvirtual and with a specific signature.
Prefer to declare copy assignment for a type T with one of the following signatures (see [Stroustrup00] and [Alexandrescu03a]):
![]()
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.
Avoid making any assignment operator virtual (see [Meyers96] §33 and [Sutter04] §19). If you think you need virtual behavior for assignment, reread those citations first. If that doesn’t ...
Read now
Unlock full access