Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
PS::Memory::AllocatorAdapter< T, Allocator > Class Template Reference

Provides a way to use untyped allocators like LinearAllocator for containers. More...

#include <AllocatorAdapter.h>

Classes

struct  rebind
 

Public Types

using value_type = T
 
using propagate_on_container_copy_assignment = std::true_type
 
using propagate_on_container_move_assignment = std::true_type
 
using propagate_on_container_swap = std::true_type
 
using is_always_equal = std::false_type
 

Public Member Functions

constexpr AllocatorAdapter (Allocator &allocator) noexcept
 
template<typename OtherT >
constexpr AllocatorAdapter (const AllocatorAdapter< OtherT, Allocator > &allocatorAdapter) noexcept
 
constexpr T * allocate (std::size_t n)
 
constexpr void deallocate (T *ptr, std::size_t n)
 
template<typename OtherT >
constexpr bool operator== (const AllocatorAdapter< OtherT, Allocator > &other) const noexcept
 

Private Attributes

Allocator * m_Allocator {nullptr}
 

Friends

template<typename OtherT , typename OtherAllocator >
class AllocatorAdapter
 

Detailed Description

template<typename T, typename Allocator>
class PS::Memory::AllocatorAdapter< T, Allocator >

Provides a way to use untyped allocators like LinearAllocator for containers.

This allocator adapter must not outlive the target allocator. A client must not mix adapters with different allocators.

It provides a basic STL allocator interface. It allows to use a stateful allocator:

std::vector<Type, PS::Memory::AllocatorAdapter<Type, PS::Memory::ScopedLinearAllocator>>

See also
ScopedLinearAllocator

Member Typedef Documentation

◆ is_always_equal

template<typename T , typename Allocator >
using PS::Memory::AllocatorAdapter< T, Allocator >::is_always_equal = std::false_type

◆ propagate_on_container_copy_assignment

template<typename T , typename Allocator >
using PS::Memory::AllocatorAdapter< T, Allocator >::propagate_on_container_copy_assignment = std::true_type

◆ propagate_on_container_move_assignment

template<typename T , typename Allocator >
using PS::Memory::AllocatorAdapter< T, Allocator >::propagate_on_container_move_assignment = std::true_type

◆ propagate_on_container_swap

template<typename T , typename Allocator >
using PS::Memory::AllocatorAdapter< T, Allocator >::propagate_on_container_swap = std::true_type

◆ value_type

template<typename T , typename Allocator >
using PS::Memory::AllocatorAdapter< T, Allocator >::value_type = T

Constructor & Destructor Documentation

◆ AllocatorAdapter() [1/2]

template<typename T , typename Allocator >
constexpr PS::Memory::AllocatorAdapter< T, Allocator >::AllocatorAdapter ( Allocator &  allocator)
inlineconstexprnoexcept

◆ AllocatorAdapter() [2/2]

template<typename T , typename Allocator >
template<typename OtherT >
constexpr PS::Memory::AllocatorAdapter< T, Allocator >::AllocatorAdapter ( const AllocatorAdapter< OtherT, Allocator > &  allocatorAdapter)
inlineconstexprnoexcept

Member Function Documentation

◆ allocate()

template<typename T , typename Allocator >
constexpr T * PS::Memory::AllocatorAdapter< T, Allocator >::allocate ( std::size_t  n)
inlineconstexpr

◆ deallocate()

template<typename T , typename Allocator >
constexpr void PS::Memory::AllocatorAdapter< T, Allocator >::deallocate ( T *  ptr,
std::size_t  n 
)
inlineconstexpr

◆ operator==()

template<typename T , typename Allocator >
template<typename OtherT >
constexpr bool PS::Memory::AllocatorAdapter< T, Allocator >::operator== ( const AllocatorAdapter< OtherT, Allocator > &  other) const
inlineconstexprnoexcept

Friends And Related Function Documentation

◆ AllocatorAdapter

template<typename T , typename Allocator >
template<typename OtherT , typename OtherAllocator >
friend class AllocatorAdapter
friend

Member Data Documentation

◆ m_Allocator

template<typename T , typename Allocator >
Allocator* PS::Memory::AllocatorAdapter< T, Allocator >::m_Allocator {nullptr}
private

The documentation for this class was generated from the following file: