public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "redi at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/45942] class will not get friends with another class
Date: Fri, 08 Oct 2010 15:08:00 -0000	[thread overview]
Message-ID: <20101008150800._1TaH12vYQBnsvcw3m7YhLg6ya3m-pZAYND-C6IX6dc@z> (raw)
In-Reply-To: <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.


  parent reply	other threads:[~2010-10-08 15:08 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-08 13:42 [Bug c++/45942] New: " MichieldeB at aim dot com
2010-10-08 14:41 ` [Bug c++/45942] " redi at gcc dot gnu.org
2010-10-08 14:46 ` redi at gcc dot gnu.org
2010-10-08 14:51 ` MichieldeB at aim dot com
2010-10-08 14:58 ` MichieldeB at aim dot com
2010-10-08 15:03 ` paolo.carlini at oracle dot com
2010-10-08 15:08 ` redi at gcc dot gnu.org [this message]
2010-10-08 15:12 ` MichieldeB at aim dot com
2010-10-08 15:36 ` redi at gcc dot gnu.org
2010-10-08 15:43 ` MichieldeB at aim dot com
2010-10-08 15:59 ` redi at gcc dot gnu.org
2010-10-08 16:09 ` MichieldeB at aim dot com
2010-10-09 13:02 ` MichieldeB at aim dot com
2010-10-09 13:38 ` MichieldeB at aim dot com
2010-10-09 18:08 ` redi at gcc dot gnu.org
2010-10-09 18:19 ` redi at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20101008150800._1TaH12vYQBnsvcw3m7YhLg6ya3m-pZAYND-C6IX6dc@z \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).