This is the mail archive of the gcc-bugs@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: egcs 2.90.23 template typedef bug report


Rob  writes:

> template <class T> struct Box {typedef T contents;};

> template <class T> struct Box2 :
> public Box <Box<T> > {contents::contents data;};

The latest snapshot of egcs prints:

test.cc:4: syntax error before `::'

There are two errors in the code snippet above:

1) whenever (well, kind of) you refer to a type name that is dependent
on template arguments, it must be prefixed by the keyword `typename'

2) If a base class is dependent on template arguments, its scope is
not used for name lookup; names from the base class must be explicitly
qualified.

This, the correct declaration of data is:

typename Box<Box<T> >::contents::contents data;

Hope this helps.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil


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