This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/45942] class will not get friends with another class


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

--- Comment #1 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-08 14:41:28 UTC ---
It's not entirely clear what you're saying is a bug, because your testcase
doesn't give any error.

It's more helpful to provide the source code that you claim produces the bug. 
I assume you this:

template <class T, int C> class classA;

template <class T, int C, classA<T,C> &instanceA> class classB;

template <class T, int C> class classA
{
  // incorrect error message: partial specialization claimed but not apparent 
  template <classA &instanceA> friend class classB<T,C,instanceA>;

private:
  int for_use_by_classB;

};

template <class T, int C, classA<T,C> &instanceA> class classB
{

  classB (int i) { instanceA.for_use_by_classB = i; }

};

// instantiation
template class classA<char,128>;


That code is not valid, the error is not incorrect.

You have declared classB as a friend, and as a template with one template
parameter, instanceA, and the template arguments <T,C,instanceA>. That is a
partial specialization.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]