Implicit typename, typedefs, and inheritance

L

lutorm

Hi all,
I'm working on migrating my code from KCC to gcc, and I'm having some
issues with "implicit typename" warnings from gcc. Essentially, what
happens is described by this example:

template <typename cell_data_type> class cell {};

template <typename a> class c1 {
public:
typedef cell<a> T_cell;
};

template <typename a> class c2 : public c1<a> {
T_cell func();
};

Trying to compile this code, results in this message from gcc:

[40]patrik@rumba:/u/patrik/sunrise/src% g++ -c typename.cc
typename.cc:9: warning: `typename c2<a>::T_cell' is implicitly a
typename
typename.cc:9: warning: implicit typename is deprecated, please see the

documentation for details

I don't understand what is implicit about this type. It's not implicit
in class c1, so how come it's implicit in class c2? The problem is not
correctable by adding typename to the offending line; this results in a
compilation error. Redefining the typedef in c2 removes the warning,
but that makes the idea of public typedefs useless...

Does this behavior makes sense to people?

Thanks,

/Patrik
 
R

Rapscallion

lutorm said:
typename.cc:9: warning: implicit typename is deprecated, please see the
documentation for details

I don't understand what is implicit about this type. It's not implicit
in class c1, so how come it's implicit in class c2? The problem is not
correctable by adding typename to the offending line; this results in a
compilation error. Redefining the typedef in c2 removes the warning,
but that makes the idea of public typedefs useless...

Does this behavior makes sense to people?

You need to add 'typename' to dependent names. See here for details:
http://womble.decadentplace.org.uk/c++/template-faq.html#disambiguation
Read also the other FAQs or you get another bunch of errors with the
next gcc release (you probably havn't compiled yet with 3.4).

R.C.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,599
Members
45,169
Latest member
ArturoOlne
Top