1// (C) Copyright John Maddock 2001. 2// Use, modification and distribution are subject to the 3// Boost Software License, Version 1.0. (See accompanying file 4// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 5 6// See http://www.boost.org/libs/config for most recent version. 7 8// MACRO: BOOST_NO_MEMBER_TEMPLATE_FRIENDS 9// TITLE: member template friends 10// DESCRIPTION: Member template friend syntax 11// ("template<class P> friend class frd;") 12// described in the C++ Standard, 13// 14.5.3, not supported. 14 15 16namespace boost_no_member_template_friends{ 17 18template <class T> 19class foobar; 20 21template <class T> 22class foo; 23 24template <class T> 25bool must_be_friend_proc(const foo<T>& f); 26 27template <class T> 28class foo 29{ 30private: 31 template<typename Y> friend class foobar; 32 template<typename Y> friend class foo; 33 template<typename Y> friend bool must_be_friend_proc(const foo<Y>& f); 34 int i; 35public: 36 foo(){ i = 0; } 37 template <class U> 38 foo(const foo<U>& f){ i = f.i; } 39}; 40 41template <class T> 42bool must_be_friend_proc(const foo<T>& f) 43{ return f.i != 0; } 44 45template <class T> 46class foobar 47{ 48 int i; 49public: 50 template <class U> 51 foobar(const foo<U>& f) 52 { i = f.i; } 53}; 54 55 56int test() 57{ 58 foo<int> fi; 59 foo<double> fd(fi); 60 must_be_friend_proc(fd); 61 foobar<long> fb(fi); 62 (void) &fb; // avoid "unused variable" warning 63 return 0; 64} 65 66} 67 68 69 70 71 72 73