inline template not expanded.
Alexandre Oliva
oliva@dcc.unicamp.br
Thu Oct 9 09:32:00 GMT 1997
turlais writes:
> An inline template function is not expanded with version egcs-2.90.12. It
> works with egcs-2.90.11.
It shouldn't.
> Remove a friend declaration of the function in a template class fix
> it.
This is expected behavior. Declare a friend non-template operator
makes the compiler expect an implementation for a non-template
operator. If you intend the compiler to use the template operator,
you should write so, as shown below.
// first, the template operator must be declared, but the
// template class must be declared before that
class str;
template <typename T>
class w;
template <typename T>
str& operator<<(str&, const w<T>&);
> template<class T>
> class w {
> // Problem with this friend declaration. Removing it fix the problem
> friend str& operator<<(str&, const w<T>&);
// note the angle brackets indicating a template function whose
// arguments can be deduced from the argument list:
friend str& operator<< <>(str&, const w<T>&);
// the template argument could have been given explicitly:
// friend str& operator<< <T>(str&, const w<T>&);
I agree this requires more typing, but the upcoming standard mandates
this behavior.
--
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