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");
30 m_Alloc(other.m_Alloc) {}
33 m_Alloc(other.m_Alloc) {}
37 m_Alloc = rhs.m_Alloc;
44 m_Alloc = rhs.m_Alloc;
50 noexcept(detail::has_nothrow_equal_v<Alloc>)
52 return m_Alloc == rhs.m_Alloc && *m_Alloc == *rhs.m_Alloc;
56 noexcept(detail::has_nothrow_not_equal_v<Alloc>)
58 return m_Alloc != rhs.m_Alloc || *m_Alloc != *rhs.m_Alloc;
61 #pragma region Allocation
63 noexcept(detail::has_nothrow_allocate_v<Alloc>)
65 return m_Alloc->allocate(n);
69 noexcept(detail::has_nothrow_deallocate_v<Alloc>)
71 m_Alloc->deallocate(p, n);
75 #pragma region Construction
76 template<
typename T,
typename... Args>
79 noexcept(detail::has_nothrow_construct_v<Alloc, T*, Args...>)
81 m_Alloc->construct(p, std::forward<Args>(args)...);
85 typename std::enable_if<detail::has_destroy_v<Alloc, T*>,
void>::type
87 noexcept(detail::has_nothrow_destroy_v<Alloc, T*>)
93 #pragma region Utility
94 template<
typename A = Alloc>
95 typename std::enable_if<detail::has_max_size_v<A>,
size_type>::type
99 return m_Alloc->max_size();
102 template<
typename A = Alloc>
103 typename std::enable_if<detail::has_owns_v<A>,
bool>::type
105 noexcept(detail::has_nothrow_owns_v<A>)
107 return m_Alloc->owns(p);
Definition: reference.h:16
void deallocate(void *p, size_t n) noexcept(detail::has_nothrow_deallocate_v< Alloc >)
Definition: reference.h:68
detail::get_size_type_t< Alloc > size_type
Definition: reference.h:18
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type destroy(T *p) noexcept(detail::has_nothrow_destroy_v< Alloc, T * >)
Definition: reference.h:86
const Alloc & get_allocator() const noexcept
Definition: reference.h:116
void * allocate(size_t n) noexcept(detail::has_nothrow_allocate_v< Alloc >)
Definition: reference.h:62
std::enable_if< detail::has_owns_v< A >, bool >::type owns(void *p) const noexcept(detail::has_nothrow_owns_v< A >)
Definition: reference.h:104
bool operator==(const reference &rhs) const noexcept(detail::has_nothrow_equal_v< Alloc >)
Definition: reference.h:49
reference & operator=(reference &&rhs) noexcept
Definition: reference.h:42
bool operator!=(const reference &rhs) const noexcept(detail::has_nothrow_not_equal_v< Alloc >)
Definition: reference.h:55
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: reference.h:78
reference(Alloc &alloc) noexcept
Constructor for forwarding any arguments to the underlying allocator.
Definition: reference.h:26
reference(const reference &other) noexcept
Definition: reference.h:29
reference(reference &&other) noexcept
Definition: reference.h:32
std::enable_if< detail::has_max_size_v< A >, size_type >::type max_size() const noexcept(detail::has_nothrow_max_size_v< A >)
Definition: reference.h:96
reference & operator=(const reference &rhs) noexcept
Definition: reference.h:35
Alloc & get_allocator() noexcept
Definition: reference.h:111
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