Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get rid of g++ hash_map deprecation warning?

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.

like image 686
Adam Avatar asked Apr 06 '09 17:04

Adam


3 Answers

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.

like image 180
Rob Kennedy Avatar answered Oct 08 '22 13:10

Rob Kennedy


I believe that that new data structure is called unordered_map

<tr1/unordered_map>

found in the std::tr1 namespace.

like image 20
Evan Teran Avatar answered Oct 08 '22 13:10

Evan Teran


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

like image 24
mgfernan Avatar answered Oct 08 '22 12:10

mgfernan