member-template bug in egcs
Alexandre Oliva
oliva@dcc.unicamp.br
Wed Nov 19 08:59:00 GMT 1997
Klaus-Georg Adams writes:
> I believe the following program should compile:
Nope, because t<int> and t<long> are different classes, and one is not
granted private access to the other.
It seems to me you should be able to declare, inside the body of
template class t:
template <class T2> friend class t;
But this is a bit ambiguous, since a template-id (t) that is not
followed by template arguments, inside the template definition, is
assumed to refer to the template-instance being defined (t<T>). It is
not clear in the Oct'97 DWP whether this declaration refers to t<T2>
or t<T>, and it is not legal to explicitly specify template arguments
as in:
template <class T2> friend class t<T2>; // [temp.friend]/8
Another approach would be to declare just the access member function
as a friend:
template <class T2> // declaring class
template <class T3> // function template argument
friend void t<T2>::access<>(const t<T3>&);
but egcs seems unable to parse this too :-(
A more restrictive approach won't help either:
template <class T2>
friend void t<T2>::access<>(const t&);
Seems like you just can't do it with egcs :-( :-(
--
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil
More information about the Gcc-bugs
mailing list