38 lines
1,023 B
C++
38 lines
1,023 B
C++
#pragma once
|
|
|
|
#include "dtcore/inc/dtdefinitions.h"
|
|
#include "dtcore/inc/dtmemory.h"
|
|
|
|
namespace dt
|
|
{
|
|
|
|
template <class T> struct StdContainerAllocator
|
|
{
|
|
typedef T value_type;
|
|
|
|
StdContainerAllocator() = default;
|
|
template <class U> constexpr StdContainerAllocator(const StdContainerAllocator<U>&) noexcept {}
|
|
|
|
T* allocate(std::size_t n);
|
|
void deallocate(T* p, std::size_t) noexcept;
|
|
};
|
|
|
|
template <class T> inline
|
|
T* StdContainerAllocator<T>::allocate(std::size_t n)
|
|
{
|
|
return static_cast<T*>(DT_ALLOC(T, static_cast<eal_u32>(n)));
|
|
}
|
|
|
|
template <class T> inline
|
|
void StdContainerAllocator<T>::deallocate(T* p, std::size_t) noexcept
|
|
{
|
|
DT_FREE(p);
|
|
}
|
|
|
|
template <class T, class U>
|
|
bool operator==(const StdContainerAllocator <T>&, const StdContainerAllocator <U>&) { return true; }
|
|
template <class T, class U>
|
|
bool operator!=(const StdContainerAllocator <T>&, const StdContainerAllocator <U>&) { return false; }
|
|
|
|
}
|
|
|