views:

428

answers:

1

I'm just experimenting with boost::pool to see if its a faster allocator for stuff I am working with, but I can't figure out how to use it with boost::unordered_map:

Here is a code snippet:

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

Here is the compile error I get:

Error 3 error C2064: term does not evaluate to a function taking 2 arguments C:\Program Files (x86)\boost\boost_1_38\boost\unordered\detail\hash_table_impl.hpp 2048

If I comment out the use of the map, e.g. "theMap[1] = 2" then the compile error goes away.

+4  A: 

It looks like you are missing a 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> > >

The fourth parameter is the predicate for comparison, the fifth is the allocator.

unordered_map<int, int, boost::hash<int>,
     std::equal_to<int>, fast_pool_allocator<int> > theMap;

Also, but probably not the cause of your issue, you need to separate the two '>' at the end of the template instantiation.

1800 INFORMATION
Thanks, that was it.
Alex Black