1 #ifndef DASH__MEMORY__UNIQUE_PTR_H__INCLUDED 2 #define DASH__MEMORY__UNIQUE_PTR_H__INCLUDED 8 template <
class Allocator>
11 template <
class Allocator>
12 constexpr
bool operator==(
16 template <
class Allocator>
19 using memory =
typename Allocator::memory_resource;
20 using pointer =
typename std::allocator_traits<Allocator>::pointer;
22 template <
class Allocator_>
23 friend constexpr
bool operator==(
35 void operator()(pointer p)
37 m_alloc.deallocate(p, m_nels);
41 Allocator m_alloc{
nullptr};
45 template <
class Allocator>
46 constexpr
bool operator==(
50 return lhs.m_alloc == rhs.m_alloc && lhs.m_nels == rhs.m_nels;
60 auto allocate_unique(
const AllocatorT &alloc, std::size_t n)
63 typename std::allocator_traits<AllocatorT>::template rebind_alloc<T>;
64 using deleter = Deleter<allocator>;
65 using unique_ptr = std::unique_ptr<T, deleter>;
67 allocator _alloc{alloc};
68 return unique_ptr{_alloc.allocate(n), deleter{_alloc, n}};
This class is a simple memory pool which holds allocates elements of size ValueType.