2009-06-30 8 views
3

그냥 boost :: pool을 사용하여 작업중인 항목에 더 빠른 할당자가 있는지 테스트하고 있는데 boost :: unordered_map과 함께 사용하는 방법을 알 수는 없습니다.boost :: unordered_map과 함께 boost :: pool_allocator를 사용하는 구문은 무엇입니까?

코드 : 3 오류 C2064

오류 : 용어는 2 인자 C를 복용 함수에 평가하지 않습니다 : \의 Program Files (x86) \ 부스트 \ boost_1_38 \ 여기

unordered_map<int,int,boost::hash<int>, fast_pool_allocator<int>> theMap; 
theMap[1] = 2; 

내가받을 컴파일 오류입니다 부스터 \ unordered \ detail \ hash_table_impl.hpp 2048

지도의 사용을 주석 처리하면 (예 : "theMap [1] = 2"그러면 컴파일 오류가 사라집니다.

답변

7

template parameter이 누락 된 것 같습니다.

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; 

또한 문제의 원인은 아니지만 템플릿 인스턴스화가 끝날 때 '>'두 개를 구분해야합니다.

+0

감사합니다. –