30 #include "BasicTypes.h" 31 #include "MemoryAllocator.h" 32 #include "DebugUtilities.h" 37 template <
typename T,
typename AllocatorType>
41 typedef value_type* pointer;
42 typedef const value_type* const_pointer;
43 typedef value_type& reference;
44 typedef const value_type& const_reference;
45 typedef std::size_t size_type;
46 typedef std::ptrdiff_t difference_type;
48 STDAllocator(AllocatorType& Allocator,
const Char* dbgDescription,
const Char* dbgFileName,
const Int32 dbgLineNumber)noexcept :
49 m_Allocator(Allocator),
50 m_dbgDescription(dbgDescription),
51 m_dbgFileName(dbgFileName),
52 m_dbgLineNumber(dbgLineNumber)
57 STDAllocator(
const STDAllocator<U, AllocatorType>& other)noexcept :
58 m_Allocator(other.m_Allocator),
59 m_dbgDescription(other.m_dbgDescription),
60 m_dbgFileName(other.m_dbgFileName),
61 m_dbgLineNumber(other.m_dbgLineNumber)
66 STDAllocator(STDAllocator<U, AllocatorType>&& other)noexcept :
67 m_Allocator(other.m_Allocator),
68 m_dbgDescription(other.m_dbgDescription),
69 m_dbgFileName(other.m_dbgFileName),
70 m_dbgLineNumber(other.m_dbgLineNumber)
75 STDAllocator& operator = (STDAllocator<U, AllocatorType>&& other)noexcept
78 VERIFY_EXPR(&m_Allocator == &other.m_Allocator);
79 m_dbgDescription = other.m_dbgDescription;
80 m_dbgFileName = other.m_dbgFileName;
81 m_dbgLineNumber = other.m_dbgLineNumber;
85 template<
class U >
struct rebind
87 typedef STDAllocator<U, AllocatorType> other;
90 T* allocate(std::size_t count)
92 return reinterpret_cast<T*
>( m_Allocator.Allocate(count *
sizeof(T), m_dbgDescription, m_dbgFileName, m_dbgLineNumber ) );
95 void deallocate(T* p, std::size_t count)
100 inline size_type max_size()
const 102 return std::numeric_limits<size_type>::max() /
sizeof(T);
106 template<
class U,
class... Args >
107 void construct( U* p, Args&&... args )
109 ::new(p) U(std::forward<Args>(args)...);
112 inline void destroy(pointer p)
117 AllocatorType &m_Allocator;
118 const Char* m_dbgDescription;
119 const Char* m_dbgFileName;
120 Int32 m_dbgLineNumber;
123 #define STD_ALLOCATOR(Type, AllocatorType, Allocator, Description) STDAllocator<Type, AllocatorType>(Allocator, Description, __FILE__, __LINE__) 125 template <
class T,
class U,
class A>
126 bool operator==(
const STDAllocator<T, A>&left,
const STDAllocator<U, A>&right)
128 return &left.m_Allocator == &right.m_Allocator;
131 template <
class T,
class U,
class A>
132 bool operator!=(
const STDAllocator<T, A> &left,
const STDAllocator<U, A> &right)
134 return !(left == right);
137 template<
class T>
using STDAllocatorRawMem = STDAllocator<T, IMemoryAllocator>;
138 #define STD_ALLOCATOR_RAW_MEM(Type, Allocator, Description) STDAllocatorRawMem<Type>(Allocator, Description, __FILE__, __LINE__) 140 template<
class T,
typename AllocatorType >
143 STDDeleter(AllocatorType &Allocator) :
144 m_Allocator(Allocator)
147 void operator()(T *ptr)
150 m_Allocator.Free(ptr);
153 AllocatorType &m_Allocator;
155 template<
class T>
using STDDeleterRawMem = STDDeleter<T, IMemoryAllocator>;
Namespace for the OpenGL implementation of the graphics engine.
Definition: BufferD3D11Impl.h:34