This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Template params in C++ functions



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]