Cogs.Foundation
Loading...
Searching...
No Matches
Classes | Functions | Variables
Cogs::Memory Namespace Reference

Classes

class  Allocator
 Base allocator implementation. More...
 
class  MemoryBuffer
 
struct  MemTypeAllocator
 
class  StdAllocator
 
class  TypedBuffer
 

Functions

template<typename T >
Tcreate (Allocator *allocator)
 Allocate storage and construct an object of the type T with the given allocator.
 
template<typename T , typename... Args>
Tcreate (Allocator *allocator, Args &&... args)
 Allocate storage and construct an object of the type T with the given allocator, using the given arguments.
 
template<typename T >
void destroy (T *t, Allocator *allocator)
 Destroy the given object and free the allocated memory using the given allocator.
 
COGSFOUNDATION_API std::string MemToHexString (const void *memory, size_t size)
 Convert a memory buffer to a nicely formatted string of hex digits for debug purposes.
 
template<class T1 , Cogs::MemBlockType memType1, class T2 , Cogs::MemBlockType memType2>
bool operator== (const MemTypeAllocator< T1, memType1 > &lhs, const MemTypeAllocator< T2, memType2 > &rhs) noexcept
 

Variables

constexpr size_t kDefaultAlignment = 8
 

Function Documentation

◆ create() [1/2]

template<typename T >
T * Cogs::Memory::create ( Allocator allocator)

Allocate storage and construct an object of the type T with the given allocator.

Template Parameters
TType of object to construct.
Returns
A pointer to the initialized object.

References Cogs::Memory::Allocator::allocate(), and Cogs::T.

◆ create() [2/2]

template<typename T , typename... Args>
T * Cogs::Memory::create ( Allocator allocator,
Args &&...  args 
)

Allocate storage and construct an object of the type T with the given allocator, using the given arguments.

Template Parameters
TType of object to construct.
Parameters
argsArguments passed on to the constructor of T.
Returns
A pointer to the initialized object.

References Cogs::Memory::Allocator::allocate(), and Cogs::T.

◆ destroy()

template<typename T >
void Cogs::Memory::destroy ( T t,
Allocator allocator 
)

Destroy the given object and free the allocated memory using the given allocator.

The memory must have been allocated using allocator.

Parameters
tPointer to an instance of type T to destruct and deallocate.
allocatorPointer to the allocator used to allocate memory for t.

References Cogs::Memory::Allocator::deallocate(), and Cogs::T.

◆ MemToHexString()

std::string Cogs::Memory::MemToHexString ( const void *  memory,
size_t  size 
)

Convert a memory buffer to a nicely formatted string of hex digits for debug purposes.

Converts the provided block of memory to a string of hex digits for debug purposes.

*============================================================================================

◆ operator==()

template<class T1 , Cogs::MemBlockType memType1, class T2 , Cogs::MemBlockType memType2>
bool Cogs::Memory::operator== ( const MemTypeAllocator< T1, memType1 > &  lhs,
const MemTypeAllocator< T2, memType2 > &  rhs 
)
noexcept

Variable Documentation

◆ kDefaultAlignment

constexpr size_t Cogs::Memory::kDefaultAlignment = 8
constexpr