unordeed_set<tuple<int,int>>
を作っているうちに、私は奇妙な問題に遭遇しました。私はVC++ 8、gcc3.2、gcc4.3を試してみましたが、すべて同じ結果があります。コンパイラがhash_value(tuple<int, int>)
の定義を見ることができないようだunorderered_set <tuple <int,int>>の方法は?
1>c:\libs\boost_1_37_0\boost\functional\hash\extensions.hpp(72) : error C2665: 'boost::hash_value' : none of the 16 overloads could convert all the argument types
1> c:\libs\boost_1_37_0\boost\functional\hash\hash.hpp(33): could be 'size_t boost::hash_value(bool)'
1> c:\libs\boost_1_37_0\boost\functional\hash\hash.hpp(34): or 'size_t boost::hash_value(char)'
1> c:\libs\boost_1_37_0\boost\functional\hash\hash.hpp(35): or 'size_t boost::hash_value(unsigned char)'
....
:ここ
#include <boost/unordered_set.hpp>
#include <boost/tuple/tuple.hpp>
// For unordered container, the declaration of operator==
#include <boost/tuple/tuple_comparison.hpp>
using namespace std ;
using namespace boost ;
// define of the hash_value funciton for tuple<int, int>
size_t hash_value(tuple<int, int> const& t) {
return get<0>(t) * 10 + get<1>(t) ;
}
int main() {
unordered_set<tuple<int, int>> s ;
tuple<int, int> t ;
s.insert(t) ;
}
は、コンパイルエラーメッセージです:私は私のコードで、次のコードで間違って何見当がつかない。しかし、tuple<int, int>
をstruct F{int a, b;}
のような他のデータ型に置き換えても機能します。それは本当に奇妙です。私は何かが欠けていますか?どうもありがとうございました。
あなたが実際にあなたのコード内でnamespace'を使用して '使用していますか?もしそうなら、それを取り出してください。 – GManNickG