bpf::memory::MemUtils class

Contents

Public static functions

template<typename T, typename... Args>
static auto New(Args && ... args) -> T*
template<typename T>
static void Delete(T* obj) noexcept
template<typename T, typename... Args>
static auto NewArray(const fsize count, Args && ... args) -> T*
template<typename T>
static void DeleteArray(T* mem, const fsize count) noexcept
template<typename T, typename... Args>
static auto ResizeArray(T* mem, const fsize oldCount, const fsize newCount, Args && ... args) -> T*

Function documentation

template<typename T, typename... Args>
static T* bpf::memory::MemUtils::New(Args && ... args)

Template parameters
T type of object to allocate
Args argument types to the constructor
Parameters
args arguments to the constructor
Returns pointer to new allocated object
Exceptions
MemoryException in case allocation is impossible

Allocates a new C++ object. WARNING: Never mix allocators

template<typename T>
static void bpf::memory::MemUtils::Delete(T* obj) noexcept

Template parameters
T type of object to free
Parameters
obj pointer to object

Frees a C++ object. WARNING: Never mix allocators

template<typename T, typename... Args>
static T* bpf::memory::MemUtils::NewArray(const fsize count, Args && ... args)

Template parameters
T type of object to allocate
Args argument types to the constructor
Parameters
count number of objects to store in the array
args arguments to the constructor
Returns pointer to new allocated array
Exceptions
MemoryException in case allocation is impossible

Allocates an array of C++ objects. WARNING: Never mix allocators

template<typename T>
static void bpf::memory::MemUtils::DeleteArray(T* mem, const fsize count) noexcept

Template parameters
T type of object to free
Parameters
mem pointer to allocated array
count number of objects stored in the array

Frees an array of C++ objects. WARNING: Never mix allocators

template<typename T, typename... Args>
static T* bpf::memory::MemUtils::ResizeArray(T* mem, const fsize oldCount, const fsize newCount, Args && ... args)

Template parameters
T type of object stored in the array
Args argument types to the constructor
Parameters
mem pointer to allocated array
oldCount current number of objects stored in the array
newCount new wanted number objects to store in the array
args arguments to the constructor
Returns pointer same array pointer or pointer to a newly allocated array
Exceptions
MemoryException in case allocation is impossible

Resize an array of C++ objects. WARNING: Never mix allocators