StormByte 2.0.0
C++26 foundation of the StormByte suite
 
Loading...
Searching...
No Matches
StormByte::Heap Namespace Reference

Allocate and free raw blocks on Base's heap. More...

Classes

struct  Allocator
 std::shared_ptr allocator that uses Allocate / Free. More...
 
struct  ObjectDeleter
 Destroy T and return its block to Free. More...
 

Functions

void * Allocate (std::size_t bytes)
 Allocate bytes on Base's heap.
 
void Free (void *pointer) noexcept
 Release a block obtained from Allocate.
 
template<class T , class... Args>
Shared< T > MakeShared (Args &&... args)
 Construct T on Base's heap and wrap it in Shared.
 
template<class T , class... Args>
Unique< T > MakeUnique (Args &&... args)
 Construct T on Base's heap and wrap it in Unique.
 

Detailed Description

Allocate and free raw blocks on Base's heap.

Declarations match the private heap.cxx definitions. The private header is not installed; public templates need these names here.

Function Documentation

◆ Allocate()

void * StormByte::Heap::Allocate ( std::size_t  bytes)

Allocate bytes on Base's heap.

Parameters
bytesBlock size in octets. Zero is forwarded to operator new.
Returns
Address of the block.
Exceptions
std::bad_allocWhen the allocator cannot satisfy the request.

◆ Free()

void StormByte::Heap::Free ( void *  pointer)
noexcept

Release a block obtained from Allocate.

Parameters
pointerBlock address, or a null pointer.

◆ MakeShared()

template<class T , class... Args>
Shared< T > StormByte::Heap::MakeShared ( Args &&...  args)

Construct T on Base's heap and wrap it in Shared.

Template Parameters
TObject type.
ArgsConstructor argument types.
Parameters
argsForwarded to T.
Returns
Owning Shared.

◆ MakeUnique()

template<class T , class... Args>
Unique< T > StormByte::Heap::MakeUnique ( Args &&...  args)

Construct T on Base's heap and wrap it in Unique.

Template Parameters
TObject type.
ArgsConstructor argument types.
Parameters
argsForwarded to T.
Returns
Owning Unique.