boost :: unord_allocator boost :: unordered_map을 사용하는 구문은 무엇입니까?
-
21-08-2019 - |
문제
나는 Boost :: Pool을 실험하기 위해 내가 작업하고있는 물건에 대한 더 빠른 할당 자인지 확인하지만 Boost :: Unordered_map을 사용하여 사용하는 방법을 알 수는 없습니다.
코드 스 니펫은 다음과 같습니다.
unordered_map<int,int,boost::hash<int>, fast_pool_allocator<int>> theMap;
theMap[1] = 2;
다음은 내가 얻는 컴파일 오류입니다.
오류 3 오류 C2064 : 용어는 2 인수 C : Program Files (x86) boost boost_1_38 boost unordered detail hash_table_impl.hpp 2048을 취하는 함수를 평가하지 않습니다.
맵의 사용과 같은 "themap [1] = 2"라면 컴파일 오류가 사라집니다.
해결책
당신이 놓친 것 같습니다 템플릿 매개 변수.
template<typename Key, typename Mapped, typename Hash = boost::hash<Key>,
typename Pred = std::equal_to<Key>,
typename Alloc = std::allocator<std::pair<Key const, Mapped> > >
네 번째 매개 변수는 비교를위한 술어이고 다섯 번째는 할당 자입니다.
unordered_map<int, int, boost::hash<int>,
std::equal_to<int>, fast_pool_allocator<int> > theMap;
또한 문제의 원인은 아니지만 템플릿 인스턴스화의 끝에서 두 '>'를 분리해야합니다.
제휴하지 않습니다 StackOverflow