...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
boost::interprocess::basic_managed_heap_memory
// In header: <boost/interprocess/managed_heap_memory.hpp> template<typename CharType, typename AllocationAlgorithm, template< class IndexConfig > class IndexType> class basic_managed_heap_memory { public: // construct/copy/destruct basic_managed_heap_memory(); basic_managed_heap_memory(std::size_t); basic_managed_heap_memory(basic_managed_heap_memory &&); basic_managed_heap_memory& operator=(basic_managed_heap_memory &&); ~basic_managed_heap_memory(); // public member functions bool grow(std::size_t) ; void swap(basic_managed_heap_memory &) ; };
A basic heap memory named object creation class. Initializes the heap memory segment. Inherits all basic functionality from basic_managed_memory_impl<CharType, AllocationAlgorithm, IndexType>
basic_managed_heap_memory
public
construct/copy/destructbasic_managed_heap_memory();
Default constructor. Does nothing. Useful in combination with move semantics
basic_managed_heap_memory(std::size_t size);
Creates heap memory and initializes the segment manager. This can throw.
basic_managed_heap_memory(basic_managed_heap_memory && moved);Moves the ownership of "moved"'s managed memory to *this. Does not throw.
basic_managed_heap_memory& operator=(basic_managed_heap_memory && moved);Moves the ownership of "moved"'s managed memory to *this. Does not throw.
~basic_managed_heap_memory();
Destructor. Liberates the heap memory holding the managed data. Never throws.
basic_managed_heap_memory
public member functionsbool grow(std::size_t extra_bytes) ;
Tries to resize internal heap memory so that we have room for more objects. WARNING: If memory is reallocated, all the objects will be binary-copied to the new buffer. To be able to use this function, all pointers constructed in this buffer must be offset pointers. Otherwise, the result is undefined. Returns true if the growth has been successful, so you will have some extra bytes to allocate new objects. If returns false, the heap allocation has failed.
void swap(basic_managed_heap_memory & other) ;
Swaps the ownership of the managed heap memories managed by *this and other. Never throws.