![]() |
Home | Libraries | People | FAQ | More |
boost::container::new_allocator
// In header: <boost/container/new_allocator.hpp> template<typename T> class new_allocator { public: // types typedef T value_type; typedef T * pointer; typedef const T * const_pointer; typedef T & reference; typedef const T & const_reference; typedef std::size_t size_type; typedef std::ptrdiff_t difference_type; typedef implementation_defined propagate_on_container_move_assignment; // A integral constant of type bool with value true. typedef implementation_defined is_always_equal; // A integral constant of type bool with value true. // member classes/structs/unions template<typename T2> struct rebind { // types typedef new_allocator< T2 > other; }; // public member functions new_allocator() noexcept; new_allocator(const new_allocator &) noexcept; new_allocator & operator=(const new_allocator &) noexcept; template<typename T2> new_allocator(const new_allocator< T2 > &) noexcept; pointer allocate(size_type); void deallocate(pointer, size_type) noexcept; size_type max_size() const noexcept; // friend functions void swap(new_allocator &, new_allocator &) noexcept; bool operator==(const new_allocator &, const new_allocator &) noexcept; bool operator!=(const new_allocator &, const new_allocator &) noexcept; };
This class is a reduced STL-compatible allocator that allocates memory using operator new or compatible calls. This allocator is stateless and can be used with any type. It supports overaligned types, even if the compiler does not support overaligned operator new. It is a drop-in replacement for std::allocator
new_allocator public member functionsnew_allocator() noexcept;
Default constructor Never throws
new_allocator(const new_allocator &) noexcept;
Constructor from other new_allocator. Never throws
new_allocator & operator=(const new_allocator &) noexcept;
Copy assignment operator from other new_allocator. Never throws
template<typename T2> new_allocator(const new_allocator< T2 > &) noexcept;
Constructor from related new_allocator. Never throws
pointer allocate(size_type count);
Allocates memory for an array of count elements. Throws bad_alloc if there is no enough memory
void deallocate(pointer ptr, size_type n) noexcept;
Deallocates previously allocated memory. Never throws
size_type max_size() const noexcept;
Returns the maximum number of elements that could be allocated. Never throws
new_allocator friend functionsvoid swap(new_allocator &, new_allocator &) noexcept;
Swaps two allocators, does nothing because this new_allocator is stateless
bool operator==(const new_allocator &, const new_allocator &) noexcept;
An new_allocator always compares to true, as memory allocated with one instance can be deallocated by another instance
bool operator!=(const new_allocator &, const new_allocator &) noexcept;
An new_allocator always compares to false, as memory allocated with one instance can be deallocated by another instance