gcc에서의 hash_map
2009/09/15 09:59
gcc에서의 hash_map 이 아직 표준이 아닌지라 다음과 같은 코드가 필요하다.
#ifdef __GNUC__ #include <ext/hash_map> #else #include <hash_map> #endifgcc의 경우 key 를 std::string 으로 잡았을 때 적절한 해시변환기가 없어서 에러를 뿜어내더라.
namespace std { using namespace __gnu_cxx; }
namespace __gnu_cxx
{
template<> struct hash< std::string >
{
size_t operator()( const std::string& x ) const
{
return hash< const char* >()( x.c_str() );
}
};
}
해당 코드를 추가함으로서 해결 할 수 있다.
