unoreded_map サポートが gcc に追加されたのはいつですか?
RHEL 5.3 に同梱されている gcc 4.1.1 を使用しています。unoreded_map が欠落しているようです。手動で追加する方法はありますか?
unoreded_map サポートが gcc に追加されたのはいつですか?
RHEL 5.3 に同梱されている gcc 4.1.1 を使用しています。unoreded_map が欠落しているようです。手動で追加する方法はありますか?
gcc にはありませんboost::unordered_map
— Boostの一部です。それは持っていstd::tr1::unordered_map
ます。少なくとも 4.0 以降に含まれています。
を使用するstd::tr1::unordered_map
には、次のヘッダーを含めます。
#include <tr1/unordered_map>
boost::unordered_map
後者は前者から作成されているため、とのインターフェースはstd::tr1::unordered_map
似ているはずです。
古いgccバージョンでは、hash_mapを使用することもできます。これは「十分」である可能性があります。
#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;
....
以降
Hash hash;
string this_string;
...
hash[ this_string ]++;
...
私はこれを頻繁に使用し、成功しました。
よろしく
rbo