This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: friend template class
- To: egcs at cygnus dot com
- Subject: Re: friend template class
- From: Nathan Myers <ncm at cygnus dot com>
- Date: Thu, 29 Oct 1998 16:09:58 -0800
- Newsgroups: cygnus.egcs
- Organization: http://www.cantrip.org/
- References: <36382F32.365E283.cygnus.egcs@iis.fhg.de>
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