9

When I compile a c++ application I'm writing that makes use of hash_map, I get this warning on g++ 4.3.2:

You are using the deprecated header . To eliminate this warning, use an ANSI-standard header file or use hte -Wno-deprecated compiler flag.

9> #include <ext/hash_map>

What include replaces this? I've searched for a while on google, and can't find anything except for people having similar problems, but no solution.

Evan Teran
  • 87,561
  • 32
  • 179
  • 238
Adam
  • 227
  • 1
  • 2
  • 6

3 Answers3

18

My very first Google hit for "g++ hash_map deprecated" takes me to a page that includes a list of things to use instead of the deprecated headers and classes.

For hash_map, the list suggests using unordered_map, in the unordered_map header. The class is new for TR1.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • For some reason I get different results on Google, but this is a perfect response. Thanks! – Adam Apr 06 '09 at 17:41
  • I guess I've just trained Google better about what sorts of results I want to see. Happy coding. – Rob Kennedy Apr 06 '09 at 17:51
  • 6
    My very first hit on Google for that query is this question on SO... Damn you, Heisenberg! (shaking my fist in the air menacingly) – Michael Burr Apr 06 '09 at 18:39
  • Also note that this is a C++11 feature so you might need to enable this in your compiler. – Chris Jul 16 '13 at 02:32
6

I believe that that new data structure is called unordered_map

<tr1/unordered_map>

found in the std::tr1 namespace.

Evan Teran
  • 87,561
  • 32
  • 179
  • 238
2

When including , do not forget to add the following compiler option; "-std=c++0x", otherwise the compiler will report an error

mgfernan
  • 783
  • 2
  • 8
  • 21