c++.beta - template friend function in another namespace
- Christof Meerwald (32/32) Jun 14 2003 struct A;
struct A; namespace ns { template<class T> void f(A &a); } struct A { template<class T> friend void ns::f(A &a); // Error: 'ns' is not a class template private: int i; }; namespace ns { template<class T> void f(A &a) { a.i = 0; // Error: member 'A::i' of class 'A' is not accessible } } int main() { A a; ns::f<int>(a); return 0; } Extracted from Boost's format library. bye, Christof -- http://cmeerw.org JID: cmeerw jabber.at mailto cmeerw at web.de ...and what have you contributed to the Net?
Jun 14 2003