-pedantic and typename

Alexandre Oliva oliva@dcc.unicamp.br
Fri Mar 6 13:10:00 GMT 1998


Gerald Pfeifer writes:

> template <class T>
> class NAMESTABLE
>     {
>     typedef /*typename*/ vector<T>::iterator iterator;
>     };

> 1) Is ``typename'' really required here?

Yes, because vector<T>::iterator is dependent on a template argument.
You must tell the compiler it is a typename, otherwise it must *not*
be considered a typename.

> 2) Even if so, and the warning is okay -- why that error? 

Not emitting the error would be wrong, and -pedantic and -ansi both
try to have a compiler that is as much ANSI/ISO C++ compliant as
possible.

> 3) According to gcc.info -pedantic only changes behavior according to
>    ANSI C. Apparently, however, it also does something similar with
>    regard to ISO C++. 

>    Should the docs be updated in this direction?

I think so.

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