16 class aligned_allocator;
21 virtual void *getAllocatorImpl() = 0;
25 virtual void *allocate(std::size_t) = 0;
26 virtual void deallocate(
void *, std::size_t) = 0;
27 virtual std::size_t getValueSize()
const = 0;
28 virtual void setAlignment(std::size_t RequiredAlign) = 0;
30 return *
reinterpret_cast<AllocatorT *
>(getAllocatorImpl());
34 template <
typename AllocatorT>
39 using EnableIfDefaultAllocator =
43 using EnableIfNonDefaultAllocator =
48 : MAllocator(Allocator),
49 MValueSize(sizeof(typename AllocatorT::value_type)) {}
52 : MAllocator(AllocatorT()),
53 MValueSize(sizeof(typename AllocatorT::value_type)) {}
57 virtual void *
allocate(std::size_t Count)
override {
58 return reinterpret_cast<void *
>(MAllocator.allocate(Count));
61 virtual void deallocate(
void *Ptr, std::size_t Count)
override {
62 MAllocator.deallocate(
63 reinterpret_cast<typename AllocatorT::value_type *
>(Ptr), Count);
67 setAlignImpl(RequiredAlign);
70 virtual std::size_t
getValueSize()
const override {
return MValueSize; }
76 template <
typename T = AllocatorT>
77 EnableIfNonDefaultAllocator<T> setAlignImpl(std::size_t) {
81 template <
typename T = AllocatorT>
82 EnableIfDefaultAllocator<T> setAlignImpl(std::size_t RequiredAlign) {
83 MAllocator.setAlignment(std::max<size_t>(RequiredAlign, 64));
86 AllocatorT MAllocator;
87 std::size_t MValueSize;