xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::memory::Placement Class Referenceabstract

Polymorphic placement for placement new. More...

#include <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.
 

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