http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45942

--- Comment #13 from Michiel <MichieldeB at aim dot com> 2010-10-09 13:38:05 
UTC ---
The reason that I did not succeed in making ClassB a friend of ClassA is that
C++ is not very logical. See below.


template <class T, int C> class classB;
template <class T, int C, class V> class classC;

template <class T, int C> class classA
{

  // classA<char,128> does NOT become friends with classA<short,512>
  friend class classB<T,C>;

  // with an extra template argument, this is only possible via 
  // specialization, which is not allowed
  template <> friend class classB<T,C>;
  template <class V> friend class classC<T,C,V>;

  // because with your solution, classA<char,128> (classB<char,128,short>)
  // DOES become friends with classA<short,512> (classB<short,512,short>)
  template <class TT, int CC> friend class classB;
  template <class TT, int CC, class VV> friend class classC;

};

template class classA<char,128>;

Reply via email to