The code
template <typename T>
void foo(const T& t)
{}
template <typename T>
class A
{
template <>
friend void foo<T>(const T& t)
{}
};
gives compile error
"defining explicit specialization ‘foo<T>’ in friend declaration friend void foo<T>(const T& t)"
when compiling with gcc and
"error C3637: 'A<int>::foo' : a friend function definition cannot be a specialization of a unction template"
when compiling in VS2013
I understand that standard says so, but why? I want to understand the reason(under the hood) There are many articles where written "An explicit specialization cannot be a friend declaration.", but I can't understand why. Any ideas?