私のコード:
typedef pair<int,int> Pair
tr1::unordered_map<Pair,bool> h;
h.insert(make_pair(Pair(0,0),true));
エラー
undefined reference to `std::tr1::hash<std::pair<int, int> >::operator()(std::pair<int, int>) const'
修正する必要があるものはありますか?
ありがとう
ベストアンサー1
std::tr1::hash<Key>
これは、の特殊化がないために発生します。を宣言する前にをKey = std::pair<int, int>
特殊化する必要があります。 これは、をハッシュする方法がわからないために発生します。std::tr1::hash<Key>
Key = std::pair<int, int>
tr1::unordered_map<Pair,bool> h;
std
pair<int, int>
以下は専門化の方法の例ですstd::tr1::hash<>
template <>
struct std::tr1::hash<std::pair<int, int> > {
public:
size_t operator()(std::pair<int, int> x) const throw() {
size_t h = SOMETHING;//something with x
return h;
}
};