hash_map iterator error
-
hi i'm want to use new GNU comipler the problem is with hash_map interator after reading some articles i added some extra macros but the didn't solve the problem compiler seems to do not recognize type template or template and in line hash_map::interator ptr; throws an error: expected `;' before "ptr" here is whole code
#include #include #include #include #if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95) /*STL extensions were put in the std namespace ...*/ namespace gnuext = std ; #elif defined(__GNUC__) && (__GNUC__>=3) /* STL extensions have their own namespace */ namespace gnuext = __gnu_cxx ; #else #error "This code relies on non-standard STL extensions as defined by GNU libraries." #endif #if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95) /*STL extensions were put in the std namespace ...*/ #define __GNUEXT std #elif defined(__GNUC__) && (__GNUC__>=3) /* STL extensions have their own namespace */ #define __GNUEXT __gnu_cxx #else #error "This code relies on non-standard STL extensions as defined by GNU libraries." #endif template class MyHash { MyHash() {} ~MyHash() {} __GNUEXT::hash_map myhash; void add(Data d) { __GNUEXT::hash_map::iterator ptr; } }; `Pain is a weakness living the body`
-
hi i'm want to use new GNU comipler the problem is with hash_map interator after reading some articles i added some extra macros but the didn't solve the problem compiler seems to do not recognize type template or template and in line hash_map::interator ptr; throws an error: expected `;' before "ptr" here is whole code
#include #include #include #include #if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95) /*STL extensions were put in the std namespace ...*/ namespace gnuext = std ; #elif defined(__GNUC__) && (__GNUC__>=3) /* STL extensions have their own namespace */ namespace gnuext = __gnu_cxx ; #else #error "This code relies on non-standard STL extensions as defined by GNU libraries." #endif #if defined(__GNUC__) && (__GNUC__==2) && (__GNUC_MINOR__>=95) /*STL extensions were put in the std namespace ...*/ #define __GNUEXT std #elif defined(__GNUC__) && (__GNUC__>=3) /* STL extensions have their own namespace */ #define __GNUEXT __gnu_cxx #else #error "This code relies on non-standard STL extensions as defined by GNU libraries." #endif template class MyHash { MyHash() {} ~MyHash() {} __GNUEXT::hash_map myhash; void add(Data d) { __GNUEXT::hash_map::iterator ptr; } }; `Pain is a weakness living the body`
ravjak wrote: __GNUEXT::hash_map::iterator ptr; try: typename __GNUEXT::hash_map::iterator ptr;
-
ravjak wrote: __GNUEXT::hash_map::iterator ptr; try: typename __GNUEXT::hash_map::iterator ptr;
-
ravjak wrote: bingo thans Fine! See also: Why do I need to add "template" and "typename" in the bodies of template definitions?[^]