xentara-utils v2.0.4
The Xentara Utility Library
Loading...
Searching...
No Matches
xentara::utils::memory::Placement Class Referenceabstract

Polymorphic placement for placement new. More...

#include <xentara/utils/memory/Placement.hpp>

Public Member Functions

virtual ~Placement ()=0
 virtual destructor
 
virtual auto allocate (std::size_t size) -> void *=0
 Allocates memory for a new object.
 
virtual auto deallocate (void *storage) noexcept -> void=0
 Deallocates memory of an already destroyed object.
 

Related Symbols

(Note that these are not member symbols.)

auto operator new (std::size_t size, xentara::utils::memory::Placement &placement) -> void *
 Placement new operator for use with Placement.
 
auto operator delete (void *block, xentara::utils::memory::Placement &placement) -> void
 Placement delete operator for use with Placement.
 
auto operator new[] (std::size_t size, xentara::utils::memory::Placement &placement) -> void *
 Array placement new operator for use with Placement.
 
auto operator delete[] (void *block, xentara::utils::memory::Placement &placement) -> void
 Placement delete operator for use with Placement.
 

Detailed Description

Polymorphic placement for placement new.

This class can be derived to allow construction of objects using placament new, where the memory needed for the object is allocated by a subclass of the placement.

Constructor & Destructor Documentation

◆ ~Placement()

xentara::utils::memory::Placement::~Placement ( )
pure virtualdefault

virtual destructor

Member Function Documentation

◆ allocate()

virtual auto xentara::utils::memory::Placement::allocate ( std::size_t  size) -> void *
pure virtual

Allocates memory for a new object.

Parameters
sizeThe size of the block
Returns
A pointer to the newly allocated memory. Must be aligned to at least alignof(std::mak_align_t)
Exceptions
std::bad_allocMemory could not be allocated

◆ deallocate()

virtual auto xentara::utils::memory::Placement::deallocate ( void *  storage) -> void
pure virtualnoexcept

Deallocates memory of an already destroyed object.

Parameters
storageA pointer to the storage of the object

Friends And Related Symbol Documentation

◆ operator delete()

auto operator delete ( void *  block,
xentara::utils::memory::Placement placement 
) -> void
related

Placement delete operator for use with Placement.

Parameters
blockThe block to delete
placementThe placement

◆ operator delete[]()

auto operator delete[] ( void *  block,
xentara::utils::memory::Placement placement 
) -> void
related

Placement delete operator for use with Placement.

Parameters
blockThe block to delete
placementThe placement

◆ operator new()

auto operator new ( std::size_t  size,
xentara::utils::memory::Placement placement 
) -> void*
related

Placement new operator for use with Placement.

To create a new object in a placement, use code like this:

auto object = new(placement) Object;
Parameters
sizeThe size of the desired block
placementThe placement
Returns
The newly allocated object

◆ operator new[]()

auto operator new[] ( std::size_t  size,
xentara::utils::memory::Placement placement 
) -> void*
related

Array placement new operator for use with Placement.

To create a new object in a placement, use code like this:

auto objectArray = new(placement) Object[count];
Parameters
sizeThe size of the desired block
placementThe placement
Returns
The newly allocated object