If you are having trouble with friend, forward the declaration before the class is defined A.
template <typename T>
bool operator== (const A<T>& a, const A<T>& b);
Then you can frienddo it more clearly. Complete solution ( ideone ):
template <typename T>
class A;
template <typename T>
bool operator== (const A<T>& a, const A<T>& b);
template <typename T>
class A {
int x;
friend bool operator==<T>(const A<T>& a, const A<T>& b);
};
template <typename T>
bool operator== (const A<T>& a, const A<T>& b) {
return a.x == b.x;
}
source
share