October 2004
Intermediate to advanced
240 pages
6h 22m
English
Specialization is good only when it can be done correctly: When extending someone else’s function template (including std::swap), avoid trying to write a specialization; instead, write an overload of the function template, and put it in the namespace of the type(s) the overload is designed to be used for. (See Item 57.) When you write your own function template, avoid encouraging direct specialization of the function template itself.
It’s okay to overload function templates. Overload resolution considers all primary templates equally, and that’s why it works as you would naturally expect from your experience with normal C++ function overloading: Whatever templates are visible are considered ...