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                                                       ;     
  typedef                                                     ;        
  typedef                                               ;  
  typedef                                                     ;      
  typedef                                               ;
  typedef                                             ;      
  typedef                                          ;
  typedef  ;        

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

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

  // public member functions
   (,  = );
   (, ) ;
   () ;
   (, , , 
                             );
   () ;
   ();
   (, );
   () ;
   () ;
   (, , );
   (, , );
   () ;

  // friend functions
   (, ) ;
   (allocator &, allocator &) ;
   (allocator &, allocator &) ;

  // private member functions
   (, , , 
                                  );
};

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. (allocator &) ;

    Constructor from other allocator. Never throws

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

    Constructor from related allocator. Never throws

allocator public member functions

  1.  ( count,  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.  ( ptr, ) ;

    Deallocates previously allocated memory. Never throws

  3.  () ;

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

  4.  ( command,  limit_size, 
                                prefer_in_recvd_out_size, 
                                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.  ( 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.  ();

    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.  ( 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.  ( 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.  ( chain) ;

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

  10.  ( 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.  ( 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.  ( chain) ;

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

allocator friend functions

  1.  (, ) ;

    Swaps two allocators, does nothing because this allocator is stateless

  2.  (allocator &, allocator &) ;

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

  3.  (allocator &, allocator &) ;

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

allocator private member functions

  1.  ( command, 
                                     limit_size, 
                                     prefer_in_recvd_out_size, 
                                     reuse_ptr);

PrevUpHomeNext