This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: list <T>::iterator _it ; fails to compile
- From: Jonathan Wakely <cow at compsoc dot man dot ac dot uk>
- To: Arnaud Gardelein <arnaud dot gardelein at polytech dot univ-nantes dot fr>
- Cc: libstdc++ at gcc dot gnu dot org
- Date: Fri, 13 Aug 2004 13:54:48 +0100
- Subject: Re: list <T>::iterator _it ; fails to compile
- References: <1092400559.29421.28.camel@irsetr09.polytech.univ-nantes.prive>
On Fri, Aug 13, 2004 at 02:36:01PM +0200, Arnaud Gardelein wrote:
> Hello !
>
> It seems that when I try to create a list iterator in a template class
> with "list<T>::iterator _it ;", gcc-3.4.0 does not like that, whereas
> version 3.2.2 does (compilation details follows) :
>
> gcc-3.4.0 :
> test.cpp:9: error: expected `;' before "_it"
>
> gcc-3.2.2 :
> test.cpp:9: warning: `typename std::list<T, std::allocator<_CharT>
> >::iterator' is implicitly a typename
> test.cpp:9: warning: implicit typename is deprecated, please see the
> documentation for details
>
> What's wrong ?
GCC 3.3.2 tells you what's wrong with the code and tells you to check
the docs to understand it. If you'd fixed the code to remove the
warning it would have made it compile with 3.4
The implicit typename feature that was deprecated in 3.3 was removed
from 3.4, so the code is no longer accepted.
You need to say "typename" before referring to a type that is dependent
on a template parameter, to tell the compiler that the name refers to
a type and not something else (such as a variable or a function).
--
"There are books in which the footnotes, or the comments scrawled by some
reader's hand in the margin, are more interesting than the text. The world
is one of those books."
- George Santayana