This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: Template params in C++ functions
- To: Piotr dot Nestorow at telelogic dot se
- Subject: Re: Template params in C++ functions
- From: Martin von Loewis <martin at mira dot isdn dot cs dot tu-berlin dot de>
- Date: Thu, 29 Oct 1998 20:49:56 +0100
- CC: egcs-bugs at cygnus dot com, egcs at cygnus dot com
- References: <m0zYrnX-00005KC@blue.telelogic.se>
> template <class ListType>
> void DeleteList (ListType *list) {
> ListType::ElementType *e;
Strictly speaking, this is invalid C++. ListType::ElementType is
considered as an object (not as a type), and the whole thing is
considered as a multiplication expression. Then, `e' is not declared,
and the code is in error.
To declare ElementType as a type, you need to write
template <class ListType>
void DeleteList (ListType *list) {
typename ListType::ElementType *e;
...
Earlier g++ versions accepted your code since »typename« is a recent
addition to C++.
egcs sometimes silently assumes 'typename' when no confusion is
possible.
Regards,
Martin