태터데스크 관리자

도움말
닫기
적용하기   첫페이지 만들기

태터데스크 메시지

저장하였습니다.

gcc에서의 hash_map

2009/09/15 09:59

gcc에서의 hash_map 이 아직 표준이 아닌지라 다음과 같은 코드가 필요하다.

#ifdef __GNUC__
#include <ext/hash_map>
#else
#include <hash_map>
#endif 

namespace std {         using namespace __gnu_cxx; }
gcc의 경우 key 를 std::string 으로 잡았을 때 적절한 해시변환기가 없어서 에러를 뿜어내더라.

namespace __gnu_cxx
{
        template<> struct hash< std::string >
        {
                size_t operator()( const std::string& x ) const
                {
                        return hash< const char* >()( x.c_str() );
                }
        };
}
해당 코드를 추가함으로서 해결 할 수 있다.
크리에이티브 커먼즈 라이선스
Creative Commons License

유리한 코드창고