11concept is_allocator =
requires (
T t,
size_t size,
size_t alignment,
void *ptr) {
12 { t.allocate(size, alignment) } -> std::same_as<void*>;
13 { t.deallocate(ptr, size) } -> std::same_as<void>;
16template<
typename Actual>
27 return reinterpret_cast<Actual*
>(
this)->
allocate(size, alignment);
39 std::enable_if_t<not std::is_void_v<T>,
T*>
45 std::enable_if_t<not std::is_void_v<T>,
T*>
50 std::enable_if_t<not std::is_void_v<T>,
void>
55 std::enable_if_t<not std::is_void_v<T>,
void>
63 std::enable_if_t<not std::is_array_v<T>, std::unique_ptr<T>>
67 std::enable_if_t<std::is_array_v<T>, std::unique_ptr<T>>
71 void dispose(std::unique_ptr<T> ptr) { deallocate<T>(ptr.release()); }
74 void dispose(std::unique_ptr<T> ptr,
size_type n) { deallocate<std::remove_extent_t<T>>(ptr.release(), n); }
std::enable_if_t< not std::is_void_v< T >, T * > allocate()
Allocate space for a single entity of type T that is aligned according to Ts alignment requirement.
void * allocate(size_type size, size_type alignment=0)
Allocate size bytes aligned to alignment.
void deallocate(void *ptr, size_type size)
Deallocate the allocation at ptr of size size.
std::enable_if_t< not std::is_array_v< T >, std::unique_ptr< T > > make_unique()
std::enable_if_t< not std::is_void_v< T >, void > deallocate(T *arr, size_type n)
Deallocate the space for an array of n entities of type T.
std::enable_if_t< not std::is_void_v< T >, void > deallocate(T *ptr)
Deallocate the space for an entity of type T at ptr.
std::enable_if_t< std::is_array_v< T >, std::unique_ptr< T > > make_unique(size_type n)
void dispose(std::unique_ptr< T > ptr, size_type n)
void dispose(std::unique_ptr< T > ptr)
std::enable_if_t< not std::is_void_v< T >, T * > allocate(size_type n)
Allocate space for an array of n entities of type T.