This is very pedantic but in C++03 it was apparently non-conforming for a program to overload (not specialize) a template function in the std
namespace: see mention of this here and long discussion on comp.lang.c++.moderated
i.e. this was ok:
namespace std
{
template <>
void swap (Foo & f, Foo & g)
{
// ...
}
}
but this was not (if I understand correctly...):
namespace std
{
template <typename T>
void swap (TempateFoo<T> & f, TempateFoo<T> & g)
{
// ...
}
}
Is this still true in C++11? Also, does this apply to template classes (like std::hash
) too, or just template functions?
EDIT: also, is there any example of a standard library implementation such that the latter would break things in practice? And if not, is there a specific reason for disallowing overloads like in the second case above? (what could potentially break in theory?)