Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class template allocator

boost::container::allocator

Synopsis

// In header: <boost/container/allocator.hpp>

template<typename T,  Version = ,  AllocationDisableMask = > 
class allocator {
public:
  // types
  typedef T                                                      ;     
  typedef T *                                                    ;        
  typedef const T *                                              ;  
  typedef T &                                                    ;      
  typedef const T &                                              ;
  typedef                                             ;      
  typedef                                          ;
  typedef Version > ;        

  // member classes/structs/unions
  template<typename T2> 
  struct rebind {
    // types
    typedef allocator< T2, Version, AllocationDisableMask > ;
  };

  // construct/copy/destruct
  () ;
  (const allocator &) ;
  template<typename T2> (const allocator< T2 > &) ;

  // public member functions
  pointer (, const void * = );
  void (pointer, ) ;
   () ;
  pointer (allocation_type, , , 
                             pointer &);
   (pointer) ;
  pointer ();
  void (, );
  void (pointer) ;
  void () ;
  void (, , );
  void (const , , );
  void () ;

  // friend functions
  void (, ) ;
  bool (const allocator &, const allocator &) ;
  bool (const allocator &, const allocator &) ;

  // private member functions
  pointer (allocation_type, , , 
                                  pointer &);
};

Description

This class is an extended STL-compatible that offers advanced allocation mechanism (in-place expansion, shrinking, burst-allocation...)

This allocator is a wrapper around a modified DLmalloc. If Version is 1, the allocator is a STL conforming allocator. If Version is 2, the allocator offers advanced expand in place and burst allocation capabilities.

AllocationDisableMask works only if Version is 2 and it can be an inclusive OR of allocation types the user wants to disable.

allocator public construct/copy/destruct

  1. () ;

    Default constructor Never throws

  2. (const allocator &) ;

    Constructor from other allocator. Never throws

  3. template<typename T2> (const allocator< T2 > &) ;

    Constructor from related allocator. Never throws

allocator public member functions

  1. pointer ( count, const void * hint = );

    Allocates memory for an array of count elements. Throws bad_alloc if there is no enough memory If Version is 2, this allocated memory can only be deallocated with deallocate() or (for Version == 2) deallocate_many()

  2. void (pointer ptr, ) ;

    Deallocates previously allocated memory. Never throws

  3.  () ;

    Returns the maximum number of elements that could be allocated. Never throws

  4. pointer (allocation_type command,  limit_size, 
                                prefer_in_recvd_out_size, 
                               pointer & reuse);

    An advanced function that offers in-place expansion shrink to fit and new allocation capabilities. Memory allocated with this function can only be deallocated with deallocate() or deallocate_many(). This function is available only with Version == 2

  5.  (pointer p) ;

    Returns maximum the number of objects the previously allocated memory pointed by p can hold. Memory must not have been allocated with allocate_one or allocate_individual. This function is available only with Version == 2

  6. pointer ();

    Allocates just one object. Memory allocated with this function must be deallocated only with deallocate_one(). Throws bad_alloc if there is no enough memory This function is available only with Version == 2

  7. void ( num_elements, 
                              chain);

    Allocates many elements of size == 1. Elements must be individually deallocated with deallocate_one() This function is available only with Version == 2

  8. void (pointer p) ;

    Deallocates memory previously allocated with allocate_one(). You should never use deallocate_one to deallocate memory allocated with other functions different from allocate_one() or allocate_individual.

  9. void ( chain) ;

    Deallocates memory allocated with allocate_one() or allocate_individual(). This function is available only with Version == 2

  10. void ( elem_size,  n_elements, 
                        chain);

    Allocates many elements of size elem_size. Elements must be individually deallocated with deallocate() This function is available only with Version == 2

  11. void (const  elem_sizes,  n_elements, 
                        chain);

    Allocates n_elements elements, each one of size elem_sizes[i] Elements must be individually deallocated with deallocate() This function is available only with Version == 2

  12. void ( chain) ;

    Deallocates several elements allocated by allocate_many(), allocate(), or allocation_command(). This function is available only with Version == 2

allocator friend functions

  1. void (, ) ;

    Swaps two allocators, does nothing because this allocator is stateless

  2. bool (const allocator &, const allocator &) ;

    An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance

  3. bool (const allocator &, const allocator &) ;

    An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance

allocator private member functions

  1. pointer (allocation_type command, 
                                     limit_size, 
                                     prefer_in_recvd_out_size, 
                                    pointer & reuse_ptr);

PrevUpHomeNext