This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: egcs 2.90.23 template typedef bug report
- To: Rob <dickrp at helsinki dot princeton dot edu>
- Subject: Re: egcs 2.90.23 template typedef bug report
- From: Alexandre Oliva <oliva at dcc dot unicamp dot br>
- Date: 25 Feb 1998 03:05:32 -0200
- Cc: egcs-bugs at cygnus dot com
- References: <199802242203.RAA28154@helsinki.princeton.edu>
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