是否可以将自己的类模板与其他模板参数声明为友元?
template<class T, class... Ts>
class A {
template<class U> friend class A<U, Ts...>; //compile error - C3772 'A<U>': invalid friend template declaration
};
最佳答案
template<class T, class... Ts>
class A {
template<class U, class... Us> friend class A; //here you go
};
A
之后不需要指定模板参数
关于c++ - 拥有自己的类模板和其他模板参数的 friend ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36217082/