diff --git a/ostd/type_traits.hh b/ostd/type_traits.hh index 5952e90..e3eb8f2 100644 --- a/ostd/type_traits.hh +++ b/ostd/type_traits.hh @@ -348,17 +348,17 @@ namespace detail { template False is_ctible_test(Any, A &&...); template - struct CtibleCore: CommonTypeBase< + constexpr bool CtibleCore = CommonTypeBase< decltype(is_ctible_test(declval_in(), declval_in()...)) - >::Type {}; + >::Type::value; /* function types are not constructible */ template - struct CtibleCore: False {}; + constexpr bool CtibleCore = false; /* scalars are default constructible, refs are not */ template - struct CtibleCore: IntegralConstant> {}; + constexpr bool CtibleCore = IsScalar; /* scalars and references are constructible from one arg if * implicitly convertible to scalar or reference */ @@ -369,56 +369,53 @@ namespace detail { }; template - struct CtibleCore: CommonTypeBase< + constexpr bool CtibleCore = CommonTypeBase< decltype(CtibleRef::test(declval_in())) - >::Type {}; + >::Type::value; /* scalars and references are not constructible from multiple args */ template - struct CtibleCore: False {}; + constexpr bool CtibleCore = false; /* treat scalars and refs separately */ template - struct CtibleVoidCheck: CtibleCore< + constexpr bool CtibleVoidCheck = CtibleCore< (IsScalar || IsReference), T, A... - > {}; + >; /* if any of T or A is void, IsConstructible should be false */ template - struct CtibleVoidCheck: False {}; + constexpr bool CtibleVoidCheck = false; - template struct CtibleContainsVoid; + template constexpr bool CtibleContainsVoid = false; - template<> struct CtibleContainsVoid<>: False {}; + template<> constexpr bool CtibleContainsVoid<> = false; template - struct CtibleContainsVoid { - static constexpr bool value = IsVoid - || CtibleContainsVoid::value; - }; + constexpr bool CtibleContainsVoid + = IsVoid || CtibleContainsVoid; /* entry point */ template - struct Ctible: CtibleVoidCheck< - CtibleContainsVoid::value || IsAbstract, - T, A... - > {}; + constexpr bool Ctible = CtibleVoidCheck< + CtibleContainsVoid || IsAbstract, T, A... + >; /* array types are default constructible if their element type is */ template - struct CtibleCore: Ctible> {}; + constexpr bool CtibleCore = Ctible>; /* otherwise array types are not constructible by this syntax */ template - struct CtibleCore: False {}; + constexpr bool CtibleCore = false; /* incomplete array types are not constructible */ template - struct CtibleCore: False {}; + constexpr bool CtibleCore = false; } /* namespace detail */ template -constexpr bool IsConstructible = detail::Ctible::value; +constexpr bool IsConstructible = detail::Ctible; /* is default constructible */ @@ -449,16 +446,16 @@ namespace detail { template False assign_test(Any, T &&); template || IsVoid> - struct IsAssignableBase: CommonTypeBase< + constexpr bool IsAssignableBase = CommonTypeBase< decltype(assign_test(declval_in(), declval_in())) - >::Type {}; + >::Type::value; template - struct IsAssignableBase: False {}; + constexpr bool IsAssignableBase = false; } /* namespace detail */ template -constexpr bool IsAssignable = detail::IsAssignableBase::value; +constexpr bool IsAssignable = detail::IsAssignableBase; /* is copy assignable */ @@ -491,63 +488,58 @@ namespace detail { static constexpr bool value = (sizeof(test(12)) == sizeof(char)); }; - template struct DtibleImpl; + template constexpr bool DtibleImpl = false; template - struct DtibleImpl: IntegralConstant>::value - > {}; + constexpr bool DtibleImpl + = IsDestructorWellformed>::value; template - struct DtibleImpl: True {}; + constexpr bool DtibleImpl = true; - template struct DtibleFalse; + template constexpr bool DtibleFalse = false; - template struct DtibleFalse - : DtibleImpl> {}; + template constexpr bool DtibleFalse + = DtibleImpl>; - template struct DtibleFalse: False {}; + template constexpr bool DtibleFalse = false; template - struct IsDestructibleBase: detail::DtibleFalse> {}; + constexpr bool IsDestructibleBase = detail::DtibleFalse>; - template struct IsDestructibleBase: False {}; - template< > struct IsDestructibleBase: False {}; + template constexpr bool IsDestructibleBase = false; + template< > constexpr bool IsDestructibleBase = false; } /* namespace detail */ template -constexpr bool IsDestructible = detail::IsDestructibleBase::value; +constexpr bool IsDestructible = detail::IsDestructibleBase; /* is trivially constructible */ namespace detail { template - struct IsTriviallyConstructibleBase: False {}; + constexpr bool IsTriviallyConstructibleBase = false; template - struct IsTriviallyConstructibleBase: IntegralConstant {}; + constexpr bool IsTriviallyConstructibleBase + = __has_trivial_constructor(T); template - struct IsTriviallyConstructibleBase: IntegralConstant {}; + constexpr bool IsTriviallyConstructibleBase + = __has_trivial_copy(T); template - struct IsTriviallyConstructibleBase: IntegralConstant {}; + constexpr bool IsTriviallyConstructibleBase + = __has_trivial_copy(T); template - struct IsTriviallyConstructibleBase: IntegralConstant {}; + constexpr bool IsTriviallyConstructibleBase + = __has_trivial_copy(T); } /* namespace detail */ template constexpr bool IsTriviallyConstructible - = detail::IsTriviallyConstructibleBase::value; + = detail::IsTriviallyConstructibleBase; /* is trivially default constructible */ @@ -568,32 +560,28 @@ template constexpr bool IsTriviallyMoveConstructible namespace detail { template - struct IsTriviallyAssignableBase: False {}; + constexpr bool IsTriviallyAssignableBase = false; template - struct IsTriviallyAssignableBase: IntegralConstant {}; + constexpr bool IsTriviallyAssignableBase + = __has_trivial_assign(T); template - struct IsTriviallyAssignableBase: IntegralConstant {}; + constexpr bool IsTriviallyAssignableBase + = __has_trivial_copy(T); template - struct IsTriviallyAssignableBase: IntegralConstant {}; + constexpr bool IsTriviallyAssignableBase + = __has_trivial_copy(T); template - struct IsTriviallyAssignableBase: IntegralConstant {}; + constexpr bool IsTriviallyAssignableBase + = __has_trivial_copy(T); } /* namespace detail */ template constexpr bool IsTriviallyAssignable - = detail::IsTriviallyAssignableBase::value; + = detail::IsTriviallyAssignableBase; /* is trivially copy assignable */ @@ -1131,29 +1119,21 @@ template struct AlignMax; + template constexpr Size AlignMax = 0; + template constexpr Size AlignMax = N; - template struct AlignMax { - static constexpr Size value = N; - }; - - template struct AlignMax { - static constexpr Size value = (N1 > N2) ? N1 : N2; - }; + template constexpr Size AlignMax + = (N1 > N2) ? N1 : N2; template - struct AlignMax { - static constexpr Size value - = AlignMax::value, N...>::value; - }; + constexpr Size AlignMax = AlignMax, N...>; template struct AlignedUnionBase { static constexpr Size alignment_value - = AlignMax::value; + = AlignMax; struct type { - alignas(alignment_value) byte data[AlignMax::value]; + alignas(alignment_value) byte data[AlignMax]; }; }; } /* namespace detail */