Discord Social SDK
Loading...
Searching...
No Matches
discordpp::SdkAllocator< T > Struct Template Reference

Detailed Description

template<typename T>
struct discordpp::SdkAllocator< T >

A standard allocator backed by Discord_Alloc and Discord_Free, so container memory comes from the backend installed with InstallAllocator rather than the global operator new.

Public Member Functions

 SdkAllocator () noexcept=default
 Constructs an allocator. The allocator is stateless, so all instances are interchangeable.
 
template<typename U>
 SdkAllocator (const SdkAllocator< U > &) noexcept
 Rebinding constructor required by the standard allocator requirements.
 
T * allocate (size_t count)
 Allocates storage for count objects of type T from the SDK's allocation backend.
 
void deallocate (T *ptr, size_t) noexcept
 Returns storage obtained from allocate to the SDK's allocation backend.
 

Public Types

using value_type = T
 The type of object this allocator allocates.
 

Member Typedef Documentation

◆ value_type

template<typename T>
using discordpp::SdkAllocator< T >::value_type = T

The type of object this allocator allocates.

Constructor & Destructor Documentation

◆ SdkAllocator() [1/2]

template<typename T>
discordpp::SdkAllocator< T >::SdkAllocator ( )
defaultnoexcept

Constructs an allocator. The allocator is stateless, so all instances are interchangeable.

◆ SdkAllocator() [2/2]

template<typename T>
template<typename U>
discordpp::SdkAllocator< T >::SdkAllocator ( const SdkAllocator< U > & )
inlinenoexcept

Rebinding constructor required by the standard allocator requirements.

Member Function Documentation

◆ allocate()

template<typename T>
T * discordpp::SdkAllocator< T >::allocate ( size_t count)
inline

Allocates storage for count objects of type T from the SDK's allocation backend.

◆ deallocate()

template<typename T>
void discordpp::SdkAllocator< T >::deallocate ( T * ptr,
size_t  )
inlinenoexcept

Returns storage obtained from allocate to the SDK's allocation backend.