When unoreded_map support was added to gcc?
I'm using gcc 4.1.1 shipped with RHEL 5.3. It looks like unoreded_map is missing. Is there a way to add it manually?
When unoreded_map support was added to gcc?
I'm using gcc 4.1.1 shipped with RHEL 5.3. It looks like unoreded_map is missing. Is there a way to add it manually?
gcc doesn't have boost::unordered_map
— it is part of Boost. It has std::tr1::unordered_map
. It is included at least since 4.0.
To use std::tr1::unordered_map
, include this header:
#include <tr1/unordered_map>
The interface of boost::unordered_map
and std::tr1::unordered_map
should be similar since the latter is created from the former.
On older gcc versions, you could also use a hash_map, which might be "good enough".
#include <ext/hash_map> // Gnu gcc specific!
...
// allow the gnu hash_map to work on std::string
namespace __gnu_cxx {
template<> struct hash< std::string > {
size_t operator()(const std::string& s) const {
return hash< const char* >()( s.c_str() );
}
}; /* gcc.gnu.org/ml/libstdc++/2002-04/msg00107.html */
}
// this is what we would love to have:
typedef __gnu_cxx::hash_map<std::string, int> Hash;
....
and later
Hash hash;
string this_string;
...
hash[ this_string ]++;
...
which I did use often and with success.
Regards
rbo