![]() |
Home | Libraries | People | FAQ | More |
boost::container::allocator
// 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 &); };
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 member functionspointer ( 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()
void (pointer ptr, ) ;
Deallocates previously allocated memory. Never throws
() ;
Returns the maximum number of elements that could be allocated. Never throws
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
(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
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
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
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.
void ( chain) ;
Deallocates memory allocated with allocate_one() or allocate_individual(). This function is available only with Version == 2
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
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
void ( chain) ;
Deallocates several elements allocated by allocate_many(), allocate(), or allocation_command(). This function is available only with Version == 2
allocator
friend functionsvoid (, ) ;
Swaps two allocators, does nothing because this allocator is stateless
bool (const allocator &, const allocator &) ;
An allocator always compares to true, as memory allocated with one instance can be deallocated by another instance
bool (const allocator &, const allocator &) ;
An allocator always compares to false, as memory allocated with one instance can be deallocated by another instance