Restrict the scope of class instances accessible by multiple template parameter friend function
问题 I would like to know if what I am aiming for is possible. I have a class Class such that #include<iostream> template<class T> class Class; template<class T, class W> Class<W> f(Class<T>& C, const Class<T>& D); template<class T> class Class { protected: // this could be private T m_t; public: Class(): m_t(T()) {} Class(T t): m_t(t) {} T& getT() { return m_t; } template<class U, class W> friend Class<W> f(Class<U>& C, const Class<U>& D); }; template<class T, class W> Class<W> f(Class<T>& C,