In C++, if you declare a template class and you would like to have a friend function that has an argument of the current class type, you need to be careful when specifying the name of the template types. For example:
template <class T>
class A {
…
template <class T>
friend void b(A<T> a);
} ;
Will confuse the compiler, as you use the same template name, T, for the class template and the function template type. What you need to do, it to use a different name for the function template type:
template <class T>
class A {
…
template <class V>
friend void b(A<V> a);
} ;
Notice that I used T for the class template type and V for the function template type.