| 1 | In section 20.4.1 [lib.default.allocator] of the C++ standard the following specialisation is defined for class std::allocator as follows:
|
|---|
| 2 |
|
|---|
| 3 | template <class T> class allocator;
|
|---|
| 4 | // specialize for void:
|
|---|
| 5 | template <> class allocator<void> {
|
|---|
| 6 | public:
|
|---|
| 7 | typedef void* pointer;
|
|---|
| 8 | typedef const void* const_pointer;
|
|---|
| 9 | // reference-to-void members are impossible.
|
|---|
| 10 | typedef void value_type;
|
|---|
| 11 | template <class U> struct rebind { typedef allocator<U> other; };
|
|---|
| 12 | };
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 | In order to use the pool allocators with multi_index_container and ease generic programming,
|
|---|
| 16 | I would suggest the following additions to pool_alloc.hpp:
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 | template<
|
|---|
| 20 | typename UserAllocator,
|
|---|
| 21 | typename Mutex,
|
|---|
| 22 | unsigned NextSize>
|
|---|
| 23 | class pool_allocator<void, UserAllocator, Mutex, NextSize> {
|
|---|
| 24 | public:
|
|---|
| 25 | typedef void* pointer;
|
|---|
| 26 | typedef const void* const_pointer;
|
|---|
| 27 | typedef void value_type;
|
|---|
| 28 | template <class U> struct rebind {
|
|---|
| 29 | typedef pool_allocator<U, UserAllocator, Mutex, NextSize> other;
|
|---|
| 30 | };
|
|---|
| 31 | };
|
|---|
| 32 |
|
|---|
| 33 | template<
|
|---|
| 34 | typename UserAllocator,
|
|---|
| 35 | typename Mutex,
|
|---|
| 36 | unsigned NextSize>
|
|---|
| 37 | class fast_pool_allocator<void, UserAllocator, Mutex, NextSize> {
|
|---|
| 38 | public:
|
|---|
| 39 | typedef void* pointer;
|
|---|
| 40 | typedef const void* const_pointer;
|
|---|
| 41 | typedef void value_type;
|
|---|
| 42 | template <class U> struct rebind {
|
|---|
| 43 | typedef fast_pool_allocator<U, UserAllocator, Mutex, NextSize> other;
|
|---|
| 44 | };
|
|---|
| 45 | };
|
|---|