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 (Piotr Nestorow)
- Subject: Re: Template params in C++ functions
- From: Joe Buck <jbuck at synopsys dot com>
- Date: Thu, 29 Oct 98 18:07:12 PST
- Cc: egcs-bugs at cygnus dot com, egcs at cygnus dot com
> When there will be support for C++ functions with template params
> in egcs?
There already is, however it conforms with the standard unlike 2.7.2.
> Example:
> ---------
> template <class ListType>
> void DeleteList (ListType *list) {
> ListType::ElementType *e;
> while ((e = list->GetFirst()) != NULL) {
> list->Remove (e);
> delete e;
> }
> }
You need to fix your code: the standard is designed to allow templates
to be parsed when first encountered. This means that you must use
the 'typename' keyword correctly to identify names that are types.
You don't have to do this for ListType, since it is a template argument,
but you do have to do it for ListType::ElementType. So the fix
is
typename ListType::ElementType *e;
> The above works in g++-2.7.2 but
> not in g++-2.8.1 or g++-egcs1.1.
2.7.2's template support was quite weak and deviated a good deal from
the standard (not its fault, the standard wasn't done yet).