Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. ATL / WTL / STL
  4. hash_map iterator error

hash_map iterator error

Scheduled Pinned Locked Moved ATL / WTL / STL
helpc++cryptography
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    ravjak
    wrote on last edited by
    #1

    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`

    C 1 Reply Last reply
    0
    • R ravjak

      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`

      C Offline
      C Offline
      CP Visitor
      wrote on last edited by
      #2

      ravjak wrote: __GNUEXT::hash_map::iterator ptr; try: typename __GNUEXT::hash_map::iterator ptr;

      R 1 Reply Last reply
      0
      • C CP Visitor

        ravjak wrote: __GNUEXT::hash_map::iterator ptr; try: typename __GNUEXT::hash_map::iterator ptr;

        R Offline
        R Offline
        ravjak
        wrote on last edited by
        #3

        bingo thans Pain is a weakness living the body

        C 1 Reply Last reply
        0
        • R ravjak

          bingo thans Pain is a weakness living the body

          C Offline
          C Offline
          CP Visitor
          wrote on last edited by
          #4

          ravjak wrote: bingo thans Fine! See also: Why do I need to add "template" and "typename" in the bodies of template definitions?[^]

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups