diff --git a/ostd/type_traits.hh b/ostd/type_traits.hh index 8f0449c..c14d719 100644 --- a/ostd/type_traits.hh +++ b/ostd/type_traits.hh @@ -223,16 +223,15 @@ namespace detail { IsUnion || IsVoid || IsReference || - IsNullPointer - > struct IsFunctionBase: IntegralConstant(function_source(0))) == 1 - > {}; + IsNullPointer> + constexpr bool IsFunctionBase + = sizeof(function_test(function_source(0))) == 1; - template struct IsFunctionBase: False {}; + template constexpr bool IsFunctionBase = false; } /* namespace detail */ template -constexpr bool IsFunction = detail::IsFunctionBase::value; +constexpr bool IsFunction = detail::IsFunctionBase; /* is arithmetic */ @@ -252,45 +251,38 @@ constexpr bool IsCompound = !IsFundamental; /* is pointer to member */ namespace detail { - template - struct IsMemberPointerBase: False {}; + template constexpr bool IsMemberPointerBase = false; template - struct IsMemberPointerBase: True {}; + constexpr bool IsMemberPointerBase = true; } template -constexpr bool IsMemberPointer = detail::IsMemberPointerBase>::value; +constexpr bool IsMemberPointer = detail::IsMemberPointerBase>; /* is pointer to member object */ namespace detail { - template - struct IsMemberObjectPointerBase: False {}; + template constexpr bool IsMemberObjectPointerBase = false; template - struct IsMemberObjectPointerBase: IntegralConstant - > {}; + constexpr bool IsMemberObjectPointerBase = !IsFunction; } template -constexpr bool IsMemberObjectPointer = detail::IsMemberObjectPointerBase>::value; +constexpr bool IsMemberObjectPointer = detail::IsMemberObjectPointerBase>; /* is pointer to member function */ namespace detail { - template - struct IsMemberFunctionPointerBase: False {}; + template constexpr bool IsMemberFunctionPointerBase = false; template - struct IsMemberFunctionPointerBase: IntegralConstant - > {}; + constexpr bool IsMemberFunctionPointerBase = IsFunction; } template -constexpr bool IsMemberFunctionPointer = detail::IsMemberFunctionPointerBase>::value; +constexpr bool IsMemberFunctionPointer = detail::IsMemberFunctionPointerBase>; /* is object */ @@ -332,34 +324,32 @@ template constexpr bool IsPolymorphic = __is_polymorphic(T); /* is signed */ namespace detail { - template - struct IsSignedCore: IntegralConstant {}; + template constexpr bool IsSignedCore = T(-1) < T(0); template> - struct IsSignedBase: False {}; + constexpr bool IsSignedBase = false; template - struct IsSignedBase: detail::IsSignedCore {}; + constexpr bool IsSignedBase = detail::IsSignedCore; } template -constexpr bool IsSigned = detail::IsSignedBase::value; +constexpr bool IsSigned = detail::IsSignedBase; /* is unsigned */ namespace detail { - template - struct IsUnsignedCore: IntegralConstant {}; + template constexpr bool IsUnsignedCore = T(0) < T(-1); template> - struct IsUnsignedBase: False {}; + constexpr bool IsUnsignedBase = false; template - struct IsUnsignedBase: detail::IsUnsignedCore {}; + constexpr bool IsUnsignedBase = detail::IsUnsignedCore; } template -constexpr bool IsUnsigned = detail::IsUnsignedBase::value; +constexpr bool IsUnsigned = detail::IsUnsignedBase; /* is standard layout */ @@ -698,41 +688,37 @@ template constexpr bool IsConvertible /* extent */ namespace detail { - template - struct ExtentBase: IntegralConstant {}; + template constexpr Size ExtentBase = 0; template - struct ExtentBase: IntegralConstant {}; + constexpr Size ExtentBase = 0; template - struct ExtentBase: - IntegralConstant::value> {}; + constexpr Size ExtentBase = detail::ExtentBase; template - struct ExtentBase: IntegralConstant {}; + constexpr Size ExtentBase = N; template - struct ExtentBase: - IntegralConstant::value> {}; + constexpr Size ExtentBase = detail::ExtentBase; } /* namespace detail */ template -constexpr Size Extent = detail::ExtentBase::value; +constexpr Size Extent = detail::ExtentBase; /* rank */ namespace detail { - template struct RankBase: IntegralConstant {}; + template constexpr Size RankBase = 0; - template struct RankBase: - IntegralConstant::value + 1> {}; + template + constexpr Size RankBase = detail::RankBase + 1; - template struct RankBase: - IntegralConstant::value + 1> {}; + template + constexpr Size RankBase = detail::RankBase + 1; } -template -constexpr Size Rank = detail::RankBase::value; +template constexpr Size Rank = detail::RankBase; /* remove const, volatile, cv */