Problem with type definition in a template class

I get an error in my template class. Here's a portion of code from my program:
1
2
3
4
5
6
7
8
                
template<typename Key, typename ItemT>
class Pool
{
    public:
           typedef typename std::pair<Key, PoolItem<ItemT> > PairType;
           typedef std::allocator<PairType, managed_shared_memory::segment_manager> ShmemAllocator;// Compile error!!!
};


It gives error in the allocator type definition. Here's the error:
include/pool.hpp:117: error: wrong number of template arguments (2, should be 1)
/usr/lib/gcc/i686-redhat-linux/4.4.2/../../../../include/c++/4.4.2/bits/stringfwd.h:45: error: provided for ‘template<class _Alloc> class std::allocator’


In Boost documentation, there's a sample like that which is compiled without any problem:
1
2
3
typedef std::pair<const int, float> ValueType;
      typedef allocator<ValueType, managed_shared_memory::segment_manager> 
         ShmemAllocator;


Here allocator takes 2 template params but in my code compiler complains about that. What is the difference?

How can i fix this compile error?
Thanks.
Compiler g++
Last edited on
Maybe the boost library defines such an allocator (one that takes two params) - i say this because the boost code you posted does not have std:: namespace in front of allocator - whereas it says std::pair
In which case, that particular boost allocator must be in a boost_namespace somewhere.

But your compiler is correct - std::allocator does not take two type parameters
Last edited on
Yes,thanks!
The allocator used in the sample is not std::allocator. I missed the point.
boost::interprocess::allocator solved the problem.
Thanks.
Topic archived. No new replies allowed.