-pedantic, and templates, and iterators --> Oh my!

llewelly@dbritsch.dsl.xmission.com llewelly@dbritsch.dsl.xmission.com
Fri Jul 7 10:38:00 GMT 2000


On Fri, 7 Jul 2000, Mark Fox wrote:
[snip]
> Here's the "minimal" test program:
> 
> ---
> #include <iostream>
> #include <list>
> 
> template <class DataType>
> class SimpleClass {
> public:
>   SimpleClass(list<DataType> const & them)
>     : _them(them.begin(), them.end())
>   {}
> 
>   DataType addThem() const {
>     list<DataType>::const_iterator
^^^^^You need typename here.

list<DatayType>::const_iterator is dependent on a template
  parameter, so the ISO C++ standard requires that typename be used to
  tell the compiler it is a type.

Note that without -pedantic, g++ can in some cases (not all) add the
  deduce that dependent names are typenames, but that is an extension.

Your code compiles fine with g++ -Wall -pedantic (version 2.95.2) once
  typename is added, so this is not a bug in gcc.

thank you for your bug report.



More information about the Gcc-bugs mailing list