g++ template instantiation warnings?

Alexandre Oliva oliva@dcc.unicamp.br
Tue Dec 16 10:08:00 GMT 1997


Brendt Wohlberg writes:

> warning: friend declaration `void swap(class A<T> &, class A<T> &)'
> warning: will not be treated as a template instantiation

> for friend declarations *without* turning them into template instantiations
> (when compiling with -fno-implicit-templates, for example)?

In fact, the error message has nothing to do with actually generating
code for template instantiations, it has to do with compiling that
declaration as referring to a template function specialization or a
non-template function.  If you don't add angle brackets, you won't be
referring to a template specialization:

void foo(int);
template <typename T> void foo(T);

class bar {
  friend void foo(int);   // refers to the non-template version
  friend void foo<>(int); // refers to the template specialization
};

Maybe the error message should be changed to say `template
specialization' instead of `template instantiation'.

-- 
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 mailing list