xentara-utils v1.2.1
Xentara utilities library
Loading...
Searching...
No Matches
xentara::utils::memory Namespace Reference

Memory tools. More...

Classes

class  ByteOffset
 A byte offset that can be used for byte-based pointer arithmetic This class A number that can be added to or subtracted from a pointer to move it by the corresponding number of bytes, as opposed to element. Also works on void pointers. More...
 
class  ControlBlockMemoryResource
 A memory resource that allocates an additional control block. More...
 
class  DestroyAt
 A wrapper around std::destroy_at() that can be used as a deleter for std::unique_ptr. More...
 
class  Embedded
 A container that contains exactly one object. More...
 
class  IndirectObject
 An object allocated indirectly on the heap. More...
 
class  Placement
 Polymorphic placement for placement new. More...
 
class  ResizableBuffer
 A buffer that can be resized if buffer space runs out. More...
 
class  SafeGlobal
 A container that holds an object that is safe from the static initialization order fiasco. More...
 
class  SizedStorage
 storage that uses short data optimization More...
 

Concepts

concept  MemoryElement
 An element in a memory region.
 
concept  MemoryIterator
 An iterator suitable for iterating over a memory region.
 
concept  MemoryRegion
 A collection suitable as a memory region.
 
concept  VoidPointer
 A concept that checks for void pointers.
 

Typedefs

template<typename Type >
using DestroyAtPointer = std::unique_ptr< Type, DestroyAt< Type > >
 std::unique_ptr that calls std::destroy_at() to destroy the object
 

Functions

constexpr auto align (std::size_t unalignedPosition, std::size_t alignment) -> std::size_t
 Finds the next suitable poisition for a block with a certain alignment.
 
template<typename LeftObject , typename RightObject >
requires std::is_swappable_with_v<LeftObject, RightObject>
auto swap (Embedded< LeftObject > &left, Embedded< RightObject > &right) noexcept(std::is_nothrow_swappable_with_v< LeftObject, RightObject >) -> void
 

Detailed Description

Memory tools.

This namespace contains tools related to memory operations like object allocation, alignment, etc.

Typedef Documentation

◆ DestroyAtPointer

template<typename Type >
using xentara::utils::memory::DestroyAtPointer = typedef std::unique_ptr<Type, DestroyAt<Type> >

std::unique_ptr that calls std::destroy_at() to destroy the object

Function Documentation

◆ align()

constexpr auto xentara::utils::memory::align ( std::size_t  unalignedPosition,
std::size_t  alignment 
) -> std::size_t
constexpr

Finds the next suitable poisition for a block with a certain alignment.

Parameters
unalignedPositionThe unaligned position
alignmentThe alignment
Returns
The smallest aligned position no smaller than unalignedPosition

◆ swap()

template<typename LeftObject , typename RightObject >
requires std::is_swappable_with_v<LeftObject, RightObject>
auto xentara::utils::memory::swap ( Embedded< LeftObject > &  left,
Embedded< RightObject > &  right 
) -> void
noexcept