Sources Pipelines Documentation

Allocators  
Public Member Functions | List of all members
boost::memory::allocation_guard< allocator_type > Class Template Referencefinal

Provides a convenient RAII-style mechanism for owning a memory block. More...

#include <allocation_guard.hpp>

Public Member Functions

 allocation_guard (allocator_type &allocator, size_t size)
 Allocates a block of given size in RAII style. More...
 
 ~allocation_guard ()
 Deallocates the block.
 
allocation_guardoperator= (const allocation_guard &other)=delete
 Not-copy assignable.
 
 operator memory_block () const
 Information about allocated underlying memory block. More...
 

Detailed Description

template<typename allocator_type>
class boost::memory::allocation_guard< allocator_type >

Provides a convenient RAII-style mechanism for owning a memory block.

RAII-style binds lifespan of the allocated block with the guard object. Usage example:

#include <boost/memory.hpp>
...
using namespace boost::memory;
mallocator allocator;
allocation_guard allocation(allocator, 200ul);
...

Definition at line 26 of file allocation_guard.hpp.

Constructor & Destructor Documentation

template<typename allocator_type >
boost::memory::allocation_guard< allocator_type >::allocation_guard ( allocator_type &  allocator,
size_t  size 
)

Allocates a block of given size in RAII style.

Using allocator instance, this constructor allocates memory block of the desired size and binds it's lifecycle with lifecycle of this guard.

Parameters
allocatorThe allocator instance to use.
sizeDesired amount of memory to allocate.

Definition at line 9 of file allocation_guard.ipp.

Member Function Documentation

template<typename allocator_type >
boost::memory::allocation_guard< allocator_type >::operator memory_block ( ) const

Information about allocated underlying memory block.

Returns
Allocated memory block.

Definition at line 25 of file allocation_guard.ipp.


The documentation for this class was generated from the following files: