public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: friend template class
       [not found] <36382F32.365E283.cygnus.egcs@iis.fhg.de>
@ 1998-10-29 19:35 ` Nathan Myers
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Myers @ 1998-10-29 19:35 UTC (permalink / raw)
  To: egcs

Christian Kueblbeck wrote:
> 
> The following piece of code does not compile:
> 
> template <class T> class Test
> {
>      friend class Friend<T>;
> };
> 
> g++ 2.7.1 compiles without warning (as well as MS Visual C++), but egcs
> says:
> 
> parse error before `<'
> 
> How else should I declare friend template class?

You need to declare Friend as a template outside Test
before you declare an instance of it as a friend inside
Test.  This compiles on egcs:

  template <class T> struct A;
  template <class T> struct B { friend struct A<T>; };

Nathan Myers
ncm@cantrip.org

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: friend template class
  1998-10-29  1:09 Christian Kueblbeck
@ 1998-10-29 18:23 ` Alexandre Oliva
  0 siblings, 0 replies; 3+ messages in thread
From: Alexandre Oliva @ 1998-10-29 18:23 UTC (permalink / raw)
  To: Christian Kueblbeck; +Cc: egcs

Christian Kueblbeck <kue@iis.fhg.de> writes:

> template <class T> class Test { friend class Friend<T>; };

> parse error before `<'

> How else should I declare friend template class?

http://egcs.cygnus.com/faq.html#friend

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:oliva@gnu.org mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


^ permalink raw reply	[flat|nested] 3+ messages in thread

* friend template class
@ 1998-10-29  1:09 Christian Kueblbeck
  1998-10-29 18:23 ` Alexandre Oliva
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Kueblbeck @ 1998-10-29  1:09 UTC (permalink / raw)
  To: egcs

The following piece of code does not compile:

template <class T> class Test
{
     friend class Friend<T>;
};

g++ 2.7.1 compiles without warning (as well as MS Visual C++), but egcs
says:

parse error before `<'

How else should I declare friend template class?

Can anyone help me?


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1998-10-29 19:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <36382F32.365E283.cygnus.egcs@iis.fhg.de>
1998-10-29 19:35 ` friend template class Nathan Myers
1998-10-29  1:09 Christian Kueblbeck
1998-10-29 18:23 ` Alexandre Oliva

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).