unordeed_set<tuple<int,int>>
을 구성하는 동안 이상한 문제가 발생했습니다. 나는 VC++ 8, gcc3.2, gcc4.3을 시도했지만, 모두 같은 결과를 보였다.정렬 순서를 설정하는 방법 <tuple <int,int>>?
#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) ;
}
이 컴파일 오류 메시지입니다 :
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)'
....
그것은 hash_value(tuple<int, int>)
의 정의를 볼 수없는 컴파일러를 보인다 나는 다음과 같은 코드에 문제가 있는지 아무 생각하는 것은 내 코드입니다. 하지만 tuple<int, int>
을 struct F{int a, b;}
과 같은 다른 데이터 형식으로 바꾸면 작동합니다. 정말 이상합니다. 나는 무엇이든 놓친다? 고맙습니다.
:
는 헤더 파일에 코드를 넣어 상자 밖으로 작동합니다 그것과 튜플의 정렬되지 않은 세트를 포함? 그렇다면 꺼내십시오. – GManNickG