This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/45942] class will not get friends with another class
- From: "redi at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 8 Oct 2010 15:08:40 +0000
- Subject: [Bug c++/45942] class will not get friends with another class
- Auto-submitted: auto-generated
- References: <bug-45942-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45942
--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> 2010-10-08 15:08:36 UTC ---
(In reply to comment #4)
> (In reply to comment #2)
> > This code is not valid, G++ is correct to reject it.
>
> Please explain why the code is invalid, and do not click "Resolved invalid"
> until ClassB is a friend of ClassA.
You reported an invalid bug, so I rejected it.
It's not my job to teach you C++ but here you go:
template <class T, int C> class A;
template <class T, int C, A<T,C> &a> class B;
template <class T, int C> class A
{
template <class X, int Y, A<X,Y>&> friend class B;
};
That makes B<X,Y,A<X,Y>&> a friend of A
Your original example is invalid for the reason the compiler gave, the syntax
you tried to use declares a partial specialization, which is not allowed in a
friend declaration. That's how C++ works, I don't make the rules.