diff --git a/ostd/internal/hashtable.hh b/ostd/internal/hashtable.hh index a7caa26..97034e0 100644 --- a/ostd/internal/hashtable.hh +++ b/ostd/internal/hashtable.hh @@ -420,7 +420,7 @@ protected: Hashtable &operator=(const Hashtable &ht) { clear(); - if (AllocatorPropagateOnContainerCopyAssignment::value) { + if (AllocatorPropagateOnContainerCopyAssignment) { if ((get_cpalloc() != ht.get_cpalloc()) && p_size) { allocator_deallocate(get_cpalloc(), p_data.first(), p_size + 1); @@ -443,7 +443,7 @@ protected: swap_adl(p_unused, ht.p_unused); swap_adl(p_data.first(), ht.p_data.first()); swap_adl(p_data.second().second(), ht.p_data.second().second()); - if (AllocatorPropagateOnContainerMoveAssignment::value) + if (AllocatorPropagateOnContainerMoveAssignment) swap_adl(p_data.second().first(), ht.p_data.second().first()); return *this; } @@ -466,7 +466,7 @@ protected: swap_adl(p_unused, ht.p_unused); swap_adl(p_data.first(), ht.p_data.first()); swap_adl(p_data.second().second(), ht.p_data.second().second()); - if (AllocatorPropagateOnContainerSwap::value) + if (AllocatorPropagateOnContainerSwap) swap_adl(p_data.second().first(), ht.p_data.second().first()); } diff --git a/ostd/memory.hh b/ostd/memory.hh index 8db68ee..ae392cd 100644 --- a/ostd/memory.hh +++ b/ostd/memory.hh @@ -324,18 +324,17 @@ namespace detail { template>, RemoveCv> - >> struct SameOrLessCvQualifiedBase: - Constant> {}; + >> constexpr bool SameOrLessCvQualifiedBase = IsConvertible; template - struct SameOrLessCvQualifiedBase: False {}; + constexpr bool SameOrLessCvQualifiedBase = false; template || IsSame || detail::HasElement::value - > struct SameOrLessCvQualified: SameOrLessCvQualifiedBase {}; + > constexpr bool SameOrLessCvQualified = SameOrLessCvQualifiedBase; template - struct SameOrLessCvQualified: False {}; + constexpr bool SameOrLessCvQualified = false; } /* namespace detail */ template @@ -359,23 +358,22 @@ public: } template explicit Box(U p, EnableIf< - detail::SameOrLessCvQualified::value, Nat + detail::SameOrLessCvQualified, Nat > = Nat()): p_stor(p, D()) { static_assert(!IsPointer, "Box constructed with null fptr deleter"); } template Box(U p, Conditional< IsReference, D, AddLvalueReference - > d, EnableIf::value, - Nat> = Nat()): p_stor(p, d) {} + > d, EnableIf, Nat> = Nat()): + p_stor(p, d) {} Box(Nullptr, Conditional, D, AddLvalueReference> d): p_stor(nullptr, d) {} template Box(U p, RemoveReference &&d, - EnableIf< - detail::SameOrLessCvQualified::value, Nat - > = Nat()): p_stor(p, move(d)) { + EnableIf, Nat> = Nat()): + p_stor(p, move(d)) { static_assert(!IsReference, "rvalue deleter cannot be a ref"); } @@ -389,7 +387,7 @@ public: template Box(Box &&u, EnableIf && detail::SameOrLessCvQualified::Pointer, - Pointer>::value + Pointer> && IsConvertible && (!IsReference || IsSame)> = Nat() ): p_stor(u.release(), forward
(u.get_deleter())) {} @@ -402,7 +400,7 @@ public: template EnableIf && detail::SameOrLessCvQualified::Pointer, - Pointer>::value + Pointer> && IsAssignable, Box & > operator=(Box &&u) { @@ -438,7 +436,7 @@ public: } template EnableIf< - detail::SameOrLessCvQualified::value, void + detail::SameOrLessCvQualified, void > reset(U p) { Pointer tmp = p_stor.first(); p_stor.first() = p; @@ -762,26 +760,23 @@ namespace detail { template struct PropagateOnContainerCopyAssignmentTest { template static char test( - typename U::PropagateOnContainerCopyAssignment * = 0); + decltype(U::PropagateOnContainerCopyAssignment) * = 0); template static int test(...); static constexpr bool value = (sizeof(test(0)) == 1); }; template::value> struct PropagateOnContainerCopyAssignmentBase { - using Type = False; - }; + >::value> constexpr bool PropagateOnContainerCopyAssignmentBase = false; template - struct PropagateOnContainerCopyAssignmentBase { - using Type = typename A::PropagateOnContainerCopyAssignment; - }; + constexpr bool PropagateOnContainerCopyAssignmentBase + = A::PropagateOnContainerCopyAssignment; } /* namespace detail */ template -using AllocatorPropagateOnContainerCopyAssignment - = typename detail::PropagateOnContainerCopyAssignmentBase::Type; +constexpr bool AllocatorPropagateOnContainerCopyAssignment + = detail::PropagateOnContainerCopyAssignmentBase; /* allocator propagate on container move assignment */ @@ -789,26 +784,23 @@ namespace detail { template struct PropagateOnContainerMoveAssignmentTest { template static char test( - typename U::PropagateOnContainerMoveAssignment * = 0); + decltype(U::PropagateOnContainerMoveAssignment) * = 0); template static int test(...); static constexpr bool value = (sizeof(test(0)) == 1); }; template::value> struct PropagateOnContainerMoveAssignmentBase { - using Type = False; - }; + >::value> constexpr bool PropagateOnContainerMoveAssignmentBase = false; template - struct PropagateOnContainerMoveAssignmentBase { - using Type = typename A::PropagateOnContainerMoveAssignment; - }; + constexpr bool PropagateOnContainerMoveAssignmentBase + = A::PropagateOnContainerMoveAssignment; } /* namespace detail */ template -using AllocatorPropagateOnContainerMoveAssignment - = typename detail::PropagateOnContainerMoveAssignmentBase::Type; +constexpr bool AllocatorPropagateOnContainerMoveAssignment + = detail::PropagateOnContainerMoveAssignmentBase; /* allocator propagate on container swap */ @@ -816,49 +808,42 @@ namespace detail { template struct PropagateOnContainerSwapTest { template static char test( - typename U::PropagateOnContainerSwap * = 0); + decltype(U::PropagateOnContainerSwap) * = 0); template static int test(...); static constexpr bool value = (sizeof(test(0)) == 1); }; template::value> - struct PropagateOnContainerSwapBase { - using Type = False; - }; + constexpr bool PropagateOnContainerSwapBase = false; template - struct PropagateOnContainerSwapBase { - using Type = typename A::PropagateOnContainerSwap; - }; + constexpr bool PropagateOnContainerSwapBase + = A::PropagateOnContainerSwap; } /* namespace detail */ template -using AllocatorPropagateOnContainerSwap - = typename detail::PropagateOnContainerSwapBase::Type; +constexpr bool AllocatorPropagateOnContainerSwap + = detail::PropagateOnContainerSwapBase; /* allocator is always equal */ namespace detail { template struct IsAlwaysEqualTest { - template static char test(typename U::IsAlwaysEqual * = 0); + template static char test(decltype(U::IsAlwaysEqual) * = 0); template static int test(...); static constexpr bool value = (sizeof(test(0)) == 1); }; template::value> - struct IsAlwaysEqualBase { - using Type = Constant>; - }; + constexpr bool IsAlwaysEqualBase = IsEmpty; template - struct IsAlwaysEqualBase { - using Type = typename A::IsAlwaysEqual; - }; + constexpr bool IsAlwaysEqualBase = A::IsAlwaysEqual; } /* namespace detail */ template -using AllocatorIsAlwaysEqual = typename detail::IsAlwaysEqualBase::Type; +constexpr bool AllocatorIsAlwaysEqual = detail::IsAlwaysEqualBase; /* allocator allocate */ @@ -878,12 +863,11 @@ namespace detail { -> False; template - struct AllocateHintTest: Constant(), - declval(), - declval())), True - > - > {}; + constexpr bool AllocateHintTest + = IsSame(), + declval(), + declval())), True + >; template inline AllocatorPointer allocate(A &a, AllocatorSize n, @@ -904,10 +888,9 @@ template inline AllocatorPointer allocator_allocate(A &a, AllocatorSize n, AllocatorConstVoidPointer h) { - return detail::allocate(a, n, h, - detail::AllocateHintTest< + return detail::allocate(a, n, h, BoolConstant, AllocatorConstVoidPointer - >()); + >>()); } /* allocator deallocate */ @@ -931,12 +914,11 @@ namespace detail { -> False; template - struct ConstructTest: Constant(), - declval(), - declval()...)), True - > - > {}; + constexpr bool ConstructTest + = IsSame(), + declval(), + declval()...)), True + >; template inline void construct(True, A &a, T *p, Args &&...args) { @@ -951,8 +933,8 @@ namespace detail { template inline void allocator_construct(A &a, T *p, Args &&...args) { - detail::construct(detail::ConstructTest(), a, p, - forward(args)...); + detail::construct(BoolConstant>(), + a, p, forward(args)...); } /* allocator destroy */ @@ -965,9 +947,8 @@ namespace detail { auto destroy_test(const A &, P &&) -> False; template - struct DestroyTest: Constant(), declval

())), True> - > {}; + constexpr bool DestroyTest + = IsSame(), declval

())), True>; template inline void destroy(True, A &a, T *p) { @@ -982,7 +963,7 @@ namespace detail { template inline void allocator_destroy(A &a, T *p) { - detail::destroy(detail::DestroyTest(), a, p); + detail::destroy(BoolConstant>(), a, p); } /* allocator max size */ @@ -995,9 +976,8 @@ namespace detail { auto alloc_max_size_test(const A &) -> False; template - struct AllocMaxSizeTest: Constant())), True> - > {}; + constexpr bool AllocMaxSizeTest + = IsSame())), True>; template inline AllocatorSize alloc_max_size(True, const A &a) { @@ -1012,7 +992,9 @@ namespace detail { template inline AllocatorSize allocator_max_size(const A &a) { - return detail::alloc_max_size(detail::AllocMaxSizeTest(), a); + return detail::alloc_max_size(BoolConstant< + detail::AllocMaxSizeTest + >(), a); } /* allocator container copy */ @@ -1025,9 +1007,8 @@ namespace detail { auto alloc_copy_test(const A &) -> False; template - struct AllocCopyTest: Constant())), True> - > {}; + constexpr bool AllocCopyTest + = IsSame())), True>; template inline AllocatorType alloc_container_copy(True, const A &a) { @@ -1042,8 +1023,8 @@ namespace detail { template inline AllocatorType allocator_container_copy(const A &a) { - return detail::alloc_container_copy(detail::AllocCopyTest< - const A + return detail::alloc_container_copy(BoolConstant< + detail::AllocCopyTest >(), a); } diff --git a/ostd/string.hh b/ostd/string.hh index 440f688..34ae138 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -340,7 +340,7 @@ public: StringBase &operator=(const StringBase &v) { if (this == &v) return *this; clear(); - if (AllocatorPropagateOnContainerCopyAssignment::value) { + if (AllocatorPropagateOnContainerCopyAssignment) { if ((p_buf.second() != v.p_buf.second()) && p_cap) { allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); p_cap = 0; @@ -360,7 +360,7 @@ public: StringBase &operator=(StringBase &&v) { clear(); if (p_cap) allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); - if (AllocatorPropagateOnContainerMoveAssignment::value) + if (AllocatorPropagateOnContainerMoveAssignment) p_buf.second() = v.p_buf.second(); p_len = v.p_len; p_cap = v.p_cap; @@ -542,7 +542,7 @@ public: detail::swap_adl(p_len, v.p_len); detail::swap_adl(p_cap, v.p_cap); detail::swap_adl(p_buf.first(), v.p_buf.first()); - if (AllocatorPropagateOnContainerSwap::value) + if (AllocatorPropagateOnContainerSwap) detail::swap_adl(p_buf.second(), v.p_buf.second()); } diff --git a/ostd/vector.hh b/ostd/vector.hh index edf30da..2bdda21 100644 --- a/ostd/vector.hh +++ b/ostd/vector.hh @@ -173,7 +173,7 @@ public: Vector &operator=(const Vector &v) { if (this == &v) return *this; clear(); - if (AllocatorPropagateOnContainerCopyAssignment::value) { + if (AllocatorPropagateOnContainerCopyAssignment) { if (p_buf.second() != v.p_buf.second() && p_cap) { allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); p_cap = 0; @@ -190,7 +190,7 @@ public: clear(); if (p_buf.first()) allocator_deallocate(p_buf.second(), p_buf.first(), p_cap); - if (AllocatorPropagateOnContainerMoveAssignment::value) + if (AllocatorPropagateOnContainerMoveAssignment) p_buf.second() = v.p_buf.second(); p_len = v.p_len; p_cap = v.p_cap; @@ -414,7 +414,7 @@ public: detail::swap_adl(p_len, v.p_len); detail::swap_adl(p_cap, v.p_cap); detail::swap_adl(p_buf.first(), v.p_buf.first()); - if (AllocatorPropagateOnContainerSwap::value) + if (AllocatorPropagateOnContainerSwap) detail::swap_adl(p_buf.second(), v.p_buf.second()); }