3 #include "../utility/aligned_malloc.h"
4 #include "../utility/alignment.h"
5 #include "../utility/empty_base.h"
6 #include "../utility/meta.h"
10 #include <type_traits>
14 template<
typename Alloc>
18 static_assert(detail::has_no_value_type_v<Alloc>,
"Building on top of typed allocators is not allowed. Use allocators without a type");
52 #pragma region Allocation
54 noexcept(detail::has_nothrow_allocate_v<Alloc>)
56 return s_Alloc.allocate(n);
60 noexcept(detail::has_nothrow_deallocate_v<Alloc>)
62 s_Alloc.deallocate(p, n);
66 #pragma region Construction
67 template<
typename T,
typename... Args>
70 noexcept(detail::has_nothrow_construct_v<Alloc, T*, Args...>)
72 s_Alloc.construct(p, std::forward<Args>(args)...);
76 typename std::enable_if<detail::has_destroy_v<Alloc, T*>,
void>::type
78 noexcept(detail::has_nothrow_destroy_v<Alloc, T*>)
84 #pragma region Utility
85 template<
typename A = Alloc>
86 typename std::enable_if<detail::has_max_size_v<A>,
size_type>::type
90 return s_Alloc.max_size();
93 template<
typename A = Alloc>
94 typename std::enable_if<detail::has_owns_v<A>,
bool>::type
96 noexcept(detail::has_nothrow_owns_v<A>)
98 return s_Alloc.owns(p);
104 s_Alloc = std::move(value);
118 static inline Alloc s_Alloc{};
bool operator==(const global &rhs) const
Definition: global.h:42
const Alloc & get_allocator() const noexcept
Definition: global.h:112
bool operator!=(const global &rhs) const
Definition: global.h:47
global & operator=(const global &rhs) noexcept
Definition: global.h:32
detail::get_size_type_t< Alloc > size_type
Definition: global.h:18
void set_allocator(Alloc &&value) noexcept
Definition: global.h:102
global(global &&other) noexcept
Definition: global.h:30
void * allocate(size_t n) noexcept(detail::has_nothrow_allocate_v< Alloc >)
Definition: global.h:53
std::enable_if< detail::has_max_size_v< A >, size_type >::type max_size() const noexcept(detail::has_nothrow_max_size_v< A >)
Definition: global.h:87
global & operator=(global &&rhs) noexcept
Definition: global.h:37
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type destroy(T *p) noexcept(detail::has_nothrow_destroy_v< Alloc, T * >)
Definition: global.h:77
global() noexcept
Constructor for forwarding any arguments to the underlying allocator.
Definition: global.h:26
global(const global &other) noexcept
Definition: global.h:28
std::enable_if< detail::has_construct_v< Alloc, T *, Args... >, void >::type construct(T *p, Args &&... args) noexcept(detail::has_nothrow_construct_v< Alloc, T *, Args... >)
Definition: global.h:69
std::enable_if< detail::has_owns_v< A >, bool >::type owns(void *p) const noexcept(detail::has_nothrow_owns_v< A >)
Definition: global.h:95
void deallocate(void *p, size_t n) noexcept(detail::has_nothrow_deallocate_v< Alloc >)
Definition: global.h:59
Alloc & get_allocator() noexcept
Definition: global.h:107
constexpr bool has_construct_v
Definition: meta.h:41
typename get_size_type< Alloc, void >::type get_size_type_t
Definition: meta.h:31
constexpr bool has_nothrow_max_size_v
Definition: meta.h:122
Definition: cascading.h:15