From b326dae1e649a977041e7e1c7c08522f08d15f11 Mon Sep 17 00:00:00 2001 From: KredeGC Date: Fri, 23 Jun 2023 16:30:56 +0200 Subject: [PATCH] Update more meta functions --- include/ktl/allocators/cascading.h | 10 ++++------ include/ktl/allocators/fallback.h | 12 ++++++------ include/ktl/allocators/freelist.h | 4 ++-- include/ktl/allocators/overflow.h | 4 ++-- include/ktl/allocators/segragator.h | 12 ++++++------ include/ktl/allocators/shared.h | 4 ++-- include/ktl/allocators/threaded.h | 4 ++-- include/ktl/allocators/type_allocator.h | 2 +- include/ktl/utility/meta.h | 16 ---------------- 9 files changed, 25 insertions(+), 43 deletions(-) diff --git a/include/ktl/allocators/cascading.h b/include/ktl/allocators/cascading.h index 227f5e8..d32a927 100644 --- a/include/ktl/allocators/cascading.h +++ b/include/ktl/allocators/cascading.h @@ -73,14 +73,12 @@ namespace ktl return *this; } - bool operator==(const cascading& rhs) const - noexcept(noexcept(m_Node == rhs.m_Node)) + bool operator==(const cascading& rhs) const noexcept { return m_Node == rhs.m_Node; } - bool operator!=(const cascading& rhs) const - noexcept(noexcept(m_Node != rhs.m_Node)) + bool operator!=(const cascading& rhs) const noexcept { return m_Node != rhs.m_Node; } @@ -177,7 +175,7 @@ namespace ktl typename std::enable_if, void>::type construct(T* p, Args&&... args) noexcept( detail::has_nothrow_owns_v && - detail::has_noexcept_construct_v) + detail::has_nothrow_construct_v) { node* next = m_Node; while (next) @@ -206,7 +204,7 @@ namespace ktl typename std::enable_if, void>::type destroy(T* p) noexcept( detail::has_nothrow_owns_v && - detail::has_noexcept_destroy_v) + detail::has_nothrow_destroy_v) { node* next = m_Node; while (next) diff --git a/include/ktl/allocators/fallback.h b/include/ktl/allocators/fallback.h index 2276a5b..c99ab12 100644 --- a/include/ktl/allocators/fallback.h +++ b/include/ktl/allocators/fallback.h @@ -35,7 +35,7 @@ namespace ktl * @brief Constructor for forwarding a single argument to the primary allocator */ template>> + typename = std::enable_if_t>> explicit fallback(Primary&& primary) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_default_constructible_v) : m_Primary(std::forward(primary)), @@ -46,8 +46,8 @@ namespace ktl */ template && - detail::can_construct_v>> + std::is_constructible_v && + std::is_constructible_v>> explicit fallback(Primary&& primary, Fallback&& fallback) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_constructible_v) : m_Primary(std::forward(primary)), @@ -58,7 +58,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit fallback(std::tuple&& primary) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_default_constructible_v) : m_Primary(std::make_from_tuple

(std::forward>(primary))), @@ -69,8 +69,8 @@ namespace ktl */ template&& - detail::can_construct_v>> + std::is_constructible_v&& + std::is_constructible_v>> explicit fallback(std::tuple&& primary, std::tuple&& fallback) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_constructible_v) : m_Primary(std::make_from_tuple

(std::forward>(primary))), diff --git a/include/ktl/allocators/freelist.h b/include/ktl/allocators/freelist.h index e4d3c08..e445a79 100644 --- a/include/ktl/allocators/freelist.h +++ b/include/ktl/allocators/freelist.h @@ -48,7 +48,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit freelist(Args&&... args) noexcept(std::is_nothrow_constructible_v) : m_Alloc(std::forward(args)...), @@ -75,7 +75,7 @@ namespace ktl freelist& operator=(const freelist&) = delete; freelist& operator=(freelist&& rhs) - noexcept(std::is_nothrow_move_constructible) + noexcept(std::is_nothrow_move_constructible_v) { release(); diff --git a/include/ktl/allocators/overflow.h b/include/ktl/allocators/overflow.h index cabfb70..05d63fd 100644 --- a/include/ktl/allocators/overflow.h +++ b/include/ktl/allocators/overflow.h @@ -177,7 +177,7 @@ namespace ktl */ template void construct(T* p, Args&&... args) noexcept( - (detail::has_construct_v && detail::has_noexcept_construct_v) || + (detail::has_construct_v && detail::has_nothrow_construct_v) || std::is_nothrow_constructible_v) { m_Constructs++; @@ -195,7 +195,7 @@ namespace ktl */ template void destroy(T* p) noexcept( - (detail::has_destroy_v&& detail::has_noexcept_destroy_v) || + (detail::has_destroy_v&& detail::has_nothrow_destroy_v) || std::is_nothrow_destructible_v) { m_Constructs--; diff --git a/include/ktl/allocators/segragator.h b/include/ktl/allocators/segragator.h index bf6a1c6..b814740 100644 --- a/include/ktl/allocators/segragator.h +++ b/include/ktl/allocators/segragator.h @@ -32,7 +32,7 @@ namespace ktl * @brief Constructor for forwarding a single argument to the primary allocator */ template>> + typename = std::enable_if_t>> explicit segragator(Primary&& primary) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_default_constructible_v) : m_Primary(std::forward(primary)), @@ -43,8 +43,8 @@ namespace ktl */ template && - detail::can_construct_v>> + std::is_constructible_v && + std::is_constructible_v>> explicit segragator(Primary&& primary, Fallback&& fallback) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_constructible_v) : m_Primary(std::forward(primary)), @@ -55,7 +55,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit segragator(std::tuple&& primary) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_default_constructible_v) : m_Primary(std::make_from_tuple

(std::forward>(primary))), @@ -66,8 +66,8 @@ namespace ktl */ template && - detail::can_construct_v>> + std::is_constructible_v && + std::is_constructible_v>> explicit segragator(std::tuple&& primary, std::tuple&& fallback) noexcept(std::is_nothrow_constructible_v && std::is_nothrow_constructible_v) : m_Primary(std::make_from_tuple

(std::forward>(primary))), diff --git a/include/ktl/allocators/shared.h b/include/ktl/allocators/shared.h index d1901a8..cd6a9d0 100644 --- a/include/ktl/allocators/shared.h +++ b/include/ktl/allocators/shared.h @@ -24,7 +24,7 @@ namespace ktl template>> + std::is_constructible_v>> block(Args&&... alloc) noexcept(std::is_nothrow_constructible_v) : Allocator(std::forward(alloc)...), @@ -44,7 +44,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit shared(Args&&... alloc) noexcept(std::is_nothrow_constructible_v) : m_Block(detail::aligned_new(detail::ALIGNMENT, std::forward(alloc)...)) {} diff --git a/include/ktl/allocators/threaded.h b/include/ktl/allocators/threaded.h index 967e518..6cb5f50 100644 --- a/include/ktl/allocators/threaded.h +++ b/include/ktl/allocators/threaded.h @@ -27,7 +27,7 @@ namespace ktl template>> + std::is_constructible_v>> block(Args&&... alloc) noexcept(std::is_nothrow_constructible_v) : Allocator(std::forward(alloc)...), @@ -48,7 +48,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit threaded(Args&&... alloc) noexcept(std::is_nothrow_constructible_v) : m_Block(detail::aligned_new(detail::ALIGNMENT, std::forward(alloc)...)) {} diff --git a/include/ktl/allocators/type_allocator.h b/include/ktl/allocators/type_allocator.h index 574ec97..0fab362 100644 --- a/include/ktl/allocators/type_allocator.h +++ b/include/ktl/allocators/type_allocator.h @@ -47,7 +47,7 @@ namespace ktl */ template>> + std::is_constructible_v>> explicit type_allocator(Args&&... alloc) noexcept(std::is_nothrow_constructible_v) : m_Alloc(std::forward(alloc)...) {} diff --git a/include/ktl/utility/meta.h b/include/ktl/utility/meta.h index 3e0cc75..4027154 100644 --- a/include/ktl/utility/meta.h +++ b/include/ktl/utility/meta.h @@ -70,16 +70,6 @@ namespace ktl::detail template constexpr bool has_owns_v = has_owns::value; - // has Alloc(Args...) - template - struct can_construct : std::false_type {}; - - template - struct can_construct()...))>, Alloc, Args...> : std::true_type {}; - - template - constexpr bool can_construct_v = can_construct::value; - // has allocate(size_t) noexcept @@ -98,9 +88,6 @@ namespace ktl::detail struct has_nothrow_construct>, Alloc, Args...> : std::bool_constant().construct(std::declval()...))> {}; - template - constexpr bool has_noexcept_construct_v = has_nothrow_construct::value; - template constexpr bool has_nothrow_construct_v = has_nothrow_construct::value; @@ -112,9 +99,6 @@ namespace ktl::detail struct has_nothrow_destroy>> : std::bool_constant().destroy(std::declval()))> {}; - template - constexpr bool has_noexcept_destroy_v = has_nothrow_destroy::value; - template constexpr bool has_nothrow_destroy_v = has_nothrow_destroy::value;