xentara-utils v2.0.4
The Xentara Utility 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.
 

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

Include file
#include <xentara/utils/memory/DestroyAt.hpp>

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