
Niels Dekker - mail address until 2008-12-31 wrote:
Joseph Gauterin wrote:
Am I correct in thinking that it's permissible to provide a template specialization of a function in namespace std but not an overload?
Yes, you are. :-) According to both the current C++ Standard and the latest Working Draft. The Draft www.open-std.org/jtc1/sc22/wg21/docs/papers/2008/n2691.pdf says at 17.4.3.1.1, Namespace std [namespace.std]:
"The behavior of a C++ program is undefined if it adds declarations or definitions to namespace std or to a namespace within namespace std unless otherwise specified. A program may add a template specialization for any standard library template to namespace std only if the declaration depends on a user-defined type of external linkage and the specialization meets the standard library requirements for the original template."
Speaking of swap, ADL, and the next standard... I remember reading or hearing a long time ago that in C++0x it is an error to call std::swap(x,y) directly and you have to do using std::swap; swap(x,y);. This seems very unfortunate especially since boost can get us ADL swap without that in C++03. Does anyone know if this is still true? Thanks, Michael Marcin