Archived

This topic is now archived and is closed to further replies.

Brobanx

The typename keyword.

Recommended Posts

I never really understood WHAT this keyword does, even after reading some technical info on MSDN. Can someone give me an example where typename actually resolves a name ambiguity?

Share this post


Link to post
Share on other sites
Without typename, in MKH''s code above, the compiler will expect SomeConcept::someother_typedef to refer to a static member variable (default case). typename tells it it isn''t so.

Documents [ GDNet | MSDN | STL | OpenGL | Formats | RTFM | Asking Smart Questions ]
C++ Stuff [ MinGW | Loki | SDL | Boost. | STLport | FLTK | ACCU Recommended Books ]

Share this post


Link to post
Share on other sites
Alright, that all makes sense now, thanks...

And as it turns out, even if a type is derived from a base class, you need to use the typename keyword when refering to that type...

I think this is a bug in GCC 3.2 i just found =/... (I'm deriving from the std::unary_function class, which has a typedef argument_type), when I use argument_type in my class, it says "implicit typename is deprecated", and if I add the typename keyword in front, it says its a parse error.. but it works properly if i say "typename unary_function::argument_type", but I shouldn't have to say it's from unary_function, because I'm deriving from it...

Is this actually a bug, should I report it to the GNU peeps?

[edited by - Brobanx on October 22, 2002 12:55:29 AM]

Share this post


Link to post
Share on other sites