• Advertisement


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

warning: implicit typename is deprecated!!

This topic is 5562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, what does this weird waring try to tell me? I'm using g++ 3.2 and his sample is using std list:
Warning part of the code (Game Programming Gems3):
template <class T>
class TAutolists { 
    virtual ~TAutolists() { 
        list<T>::iterator pos = ms_List.find( static_cast<T*>(this) ); // <----

        ms_List.remove_at( pos ); 

And I get this warning:
misc/TAutolists.h: In destructor `virtual 
misc/TAutolists.h:22: warning: `typename std::list<T, 
   std::allocator<_CharT> >::iterator' is implicitly a typename
misc/TAutolists.h:22: warning: implicit typename is deprecated, 
   please see the documentation for details
What's wrong with above code? How to do it with non-deprecated style? [edited by - stefu on December 25, 2002 2:21:20 PM]

Share this post

Link to post
Share on other sites
As list<T> is a templated type, the compiler cannot know whether list<T>::iterator is a member typedef or a member variable untill you specified what T you are working with. Some specializations of list might define it differently.

Since, by default the compiler assumes that the name refers to member variable, you have to indicate explicitely that it refers to a type name, using the typename keyword.

typename list<T>::iterator pos = ms_List.find( static_cast<T*>(this) );

Edit: I just realise my sentence made no sense at all... that should be better.

[ Start Here ! | How To Ask Smart Questions | Recommended C++ Books | C++ FAQ Lite | Function Ptrs | CppTips Archive ]
[ Header Files | File Format Docs | LNK2001 | C++ STL Doc | STLPort | Free C++ IDE | Boost C++ Lib | MSVC6 Lib Fixes ]

[edited by - Fruny on December 26, 2002 1:35:24 AM]

Share this post

Link to post
Share on other sites

  • Advertisement