| Home | Libraries | People | FAQ | More

## Class template basic_managed_heap_memory

boost::interprocess::basic_managed_heap_memory

## Synopsis

    // 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 &);
    };

## Description

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/destruct

1.     basic_managed_heap_memory();

   Default constructor. Does nothing. Useful in combination with move semantics

2.     basic_managed_heap_memory(std::size_t size);

   Creates heap memory and initializes the segment manager. This can throw.

3.     basic_managed_heap_memory(basic_managed_heap_memory && moved);

   Moves the ownership of "moved"'s managed memory to *this. Does not throw.

4.     basic_managed_heap_memory& operator=(basic_managed_heap_memory && moved);

   Moves the ownership of "moved"'s managed memory to *this. Does not throw.

5.     ~basic_managed_heap_memory();

   Destructor. Liberates the heap memory holding the managed data. Never throws.

### `basic_managed_heap_memory` public member functions

1.     bool 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.

2.     void swap(basic_managed_heap_memory & other);

   Swaps the ownership of the managed heap memories managed by *this and other. Never throws.