I want to make A<T>
a friend of A<T2>
for any types T
and T2
.
Is this possible?
Thanks.
Test (also at godbolt.org):
template <class T>
class A {
public:
template <typename T2> void test(A<T2>& a) { a.v_ = 2;}
private:
int v_;
template <typename T2> friend A;
};
int main() {
A<int> a;
A<int> b;
b.test(a);
return 0;
}
Compiler Error:
<source>:7:28: error: friend type templates must use an elaborated type
template <typename T2> friend A;
^~~~~~~~