Boost C++ Libraries Home Libraries People FAQ More

PrevUpHomeNext

Class memory_resource

boost::container::pmr::memory_resource

Synopsis

// In header: <boost/container/pmr/memory_resource.hpp>


class memory_resource {
public:
  // construct/copy/destruct
  ~();

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

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

  // protected member functions
   (, ) = ;
   (, , ) = ;
   (memory_resource &) ;

  // public data members
  static  max_align;
};

Description

The memory_resource class is an abstract interface to an unbounded set of classes encapsulating memory resources.

memory_resource public construct/copy/destruct

  1. ~();

    Effects: Destroys this memory_resource.

memory_resource public member functions

  1.  ( bytes,  alignment = );

    Effects: Equivalent to return do_allocate(bytes, alignment);

  2.  ( p,  bytes,  alignment = );

    Effects: Equivalent to return do_deallocate(bytes, alignment);

  3.  (memory_resource & other) ;

    Effects: Equivalent to return do_is_equal(other);

memory_resource friend functions

  1.  (memory_resource & a, memory_resource & b) ;

    Returns: &a == &b || a.is_equal(b).

  2.  (memory_resource & a, memory_resource & b) ;

    Returns: !(a == b).

memory_resource protected member functions

  1.  ( bytes,  alignment) = ;

    Requires: Alignment shall be a power of two.

    Returns: A derived class shall implement this function to return a pointer to allocated storage with a size of at least bytes. The returned storage is aligned to the specified alignment, if such alignment is supported; otherwise it is aligned to max_align.

    Throws: A derived class implementation shall throw an appropriate exception if it is unable to allocate memory with the requested size and alignment.

  2.  
    ( p,  bytes,  alignment) = ;

    Requires: p shall have been returned from a prior call to allocate(bytes, alignment) on a memory resource equal to *this, and the storage at p shall not yet have been deallocated.

    Effects: A derived class shall implement this function to dispose of allocated storage.

    Throws: Nothing.

  3.  (memory_resource & other) ;

    Returns: A derived class shall implement this function to return true if memory allocated from this can be deallocated from other and vice-versa; otherwise it shall return false. [Note: The most-derived type of other might not match the type of this. For a derived class, D, a typical implementation of this function will compute dynamic_cast<const D*>(&other) and go no further (i.e., return false) if it returns nullptr. - end note].


PrevUpHomeNext