Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize>

boost::pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize> — Specialization of pool_allocator<void>.

Synopsis

// In header: <boost/pool/pool_alloc.hpp>

template<typename UserAllocator, typename Mutex, unsigned NextSize, 
         unsigned MaxSize> 
class pool_allocator<void, UserAllocator, Mutex, NextSize, MaxSize> {
public:
  // types
  typedef void *                                 pointer;        
  typedef const void *                           const_pointer;  
  typedef void                                   value_type;     
  typedef UserAllocator                          user_allocator;   // allocator that defines the method that the underlying Pool will use to allocate memory from the system. 
  typedef Mutex                                  mutex;            // typedef mutex publishes the value of the template parameter Mutex. 
  typedef value_type &                           reference;      
  typedef const value_type &                     const_reference;
  typedef pool< UserAllocator >::size_type       size_type;      
  typedef pool< UserAllocator >::difference_type difference_type;

  // member classes/structs/unions

  // Nested class rebind allows for transformation from pool_allocator<T> to pool_allocator<underline>. </underline>
  template<typename U> 
  struct rebind {
    // types
    typedef pool_allocator< U, UserAllocator, Mutex, NextSize, MaxSize > other;
  };

  // public member functions
  pool_allocator();
  bool operator==(const pool_allocator &) const;
  bool operator!=(const pool_allocator &) const;

  // public static functions
  static pointer address(reference);
  static size_type max_size();
  static void construct(const pointer, const value_type &);
  static void destroy(const pointer);
  static pointer allocate(const size_type);
  static void deallocate(const pointer, const size_type);

  // public data members
  static const unsigned next_size;  // next_size publishes the values of the template parameter NextSize. 
};

Description

Specialization of pool_allocator for type void: required by the standard to make this a conforming allocator type.

pool_allocator public member functions

  1. pool_allocator();

    Results in default construction of the underlying singleton_pool IFF an instance of this allocator is constructed during global initialization ( required to ensure construction of singleton_pool IFF an instance of this allocator is constructed during global initialization. See ticket #2359 for a complete explanation at http://svn.boost.org/trac/boost/ticket/2359) .

  2. bool operator==(const pool_allocator &) const;
  3. bool operator!=(const pool_allocator &) const;

pool_allocator public static functions

  1. static pointer address(reference r);
  2. static size_type max_size();
  3. static void construct(const pointer ptr, const value_type & t);
  4. static void destroy(const pointer ptr);
  5. static pointer allocate(const size_type n);
  6. static void deallocate(const pointer ptr, const size_type n);

    Deallocate n bytes from ptr

    Parameters:

    ptr

    location to deallocate from.

    n

    number of bytes to deallocate.


PrevUpHomeNext