3#include "../utility/aligned_malloc.h"
4#include "../utility/alignment.h"
5#include "../utility/empty_base.h"
6#include "../utility/meta.h"
7#include "../utility/source_location.h"
17 template<
typename Alloc>
26 template<
typename A = Alloc>
28 noexcept(std::is_nothrow_default_constructible_v<Alloc>) :
35 template<
typename... Args,
36 typename = std::enable_if_t<
37 std::is_constructible_v<Alloc, Args...>>>
39 noexcept(std::is_nothrow_constructible_v<Alloc, Args...>) :
40 m_Alloc(std::forward<Args>(args) ...),
52 return m_Alloc == rhs.m_Alloc;
58 return m_Alloc != rhs.m_Alloc;
61#pragma region Allocation
63 noexcept(detail::has_nothrow_allocate_v<Alloc>)
67 std::lock_guard<std::mutex> lock(m_Lock);
69 return m_Alloc.allocate(n, source);
71 catch (
const std::system_error&)
82 std::lock_guard<std::mutex> lock(m_Lock);
84 m_Alloc.deallocate(p, n);
86 catch (
const std::system_error&) {}
90#pragma region Construction
91 template<
typename T,
typename... Args>
98 m_Alloc.construct(p, std::forward<Args>(args)...);
102 typename std::enable_if<detail::has_destroy_v<Alloc, T*>,
void>::type
112#pragma region Utility
113 template<
typename A = Alloc>
114 typename std::enable_if<detail::has_max_size_v<A>,
size_type>::type
116 noexcept(detail::has_nothrow_max_size_v<A>)
118 return m_Alloc.max_size();
121 template<
typename A = Alloc>
122 typename std::enable_if<detail::has_owns_v<A>,
bool>::type
126 return m_Alloc.owns(p);
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 threaded.h:93
bool operator!=(const threaded &rhs) const noexcept(detail::has_nothrow_not_equal_v< Alloc >)
Definition threaded.h:55
threaded(threaded &&)=delete
std::enable_if< detail::has_owns_v< A >, bool >::type owns(void *p) const noexcept(detail::has_nothrow_owns_v< A >)
Definition threaded.h:123
void * allocate(size_t n, const source_location source=KTL_SOURCE()) noexcept(detail::has_nothrow_allocate_v< Alloc >)
Definition threaded.h:62
bool operator==(const threaded &rhs) const noexcept(detail::has_nothrow_equal_v< Alloc >)
Definition threaded.h:49
std::enable_if< detail::has_max_size_v< A >, size_type >::type max_size() const noexcept(detail::has_nothrow_max_size_v< A >)
Definition threaded.h:115
Alloc & get_allocator() noexcept
Definition threaded.h:130
threaded(Args &&... args) noexcept(std::is_nothrow_constructible_v< Alloc, Args... >)
Constructor for forwarding any arguments to the underlying allocator.
Definition threaded.h:38
threaded & operator=(threaded &&)=delete
void deallocate(void *p, size_t n) noexcept(detail::has_nothrow_deallocate_v< Alloc >)
Definition threaded.h:77
const Alloc & get_allocator() const noexcept
Definition threaded.h:135
threaded & operator=(const threaded &)=delete
threaded() noexcept(std::is_nothrow_default_constructible_v< Alloc >)
Definition threaded.h:27
threaded(const threaded &)=delete
std::enable_if< detail::has_destroy_v< Alloc, T * >, void >::type destroy(T *p) noexcept(detail::has_nothrow_destroy_v< Alloc, T * >)
Definition threaded.h:103
detail::get_size_type_t< Alloc > size_type
Definition threaded.h:24
#define KTL_EMPTY_BASE
Definition empty_base.h:6
typename get_size_type< Alloc, void >::type get_size_type_t
Definition meta.h:33
constexpr bool has_nothrow_construct_v
Definition meta.h:123
constexpr bool has_construct_v
Definition meta.h:53
constexpr bool has_no_value_type_v
Definition meta.h:17
Definition cascading.h:16
#define KTL_SOURCE()
Definition source_location.h:11
Definition source_location.h:19