diff --git a/ostd/functional.hh b/ostd/functional.hh index 1ad6485..4179c9d 100644 --- a/ostd/functional.hh +++ b/ostd/functional.hh @@ -696,14 +696,10 @@ namespace detail { }; template - struct IsValidFunctor { - static constexpr bool value = false; - }; + constexpr bool IsValidFunctor = false; template - struct IsValidFunctor, R(A...)> { - static constexpr bool value = false; - }; + constexpr bool IsValidFunctor, R(A...)> = false; template T func_to_functor(T &&f) { @@ -722,19 +718,17 @@ namespace detail { return mem_fn(f); } + struct ValidFunctorNat {}; + + template + static decltype(func_to_functor(declval()) (declval()...)) + valid_functor_test(U *); + template + static ValidFunctorNat valid_functor_test(...); + template - struct IsValidFunctor { - struct Nat {}; - - template - static decltype(func_to_functor(declval()) (declval()...)) - test(U *); - template - static Nat test(...); - - static constexpr bool value - = IsConvertible(nullptr)), R>; - }; + constexpr bool IsValidFunctor + = IsConvertible(nullptr)), R>; template using FunctorType = decltype(func_to_functor(declval())); @@ -755,7 +749,7 @@ struct Function: detail::FunctionBase { } template::value + detail::IsValidFunctor >> Function(T f) { if (func_is_null(f)) { init_empty(); @@ -801,7 +795,7 @@ struct Function: detail::FunctionBase { } template::value + detail::IsValidFunctor >> Function(AllocatorArg, const A &a, T f) { if (func_is_null(f)) { init_empty(); @@ -905,16 +899,15 @@ namespace detail { using Obj = Function; }; - template - struct DcFuncTest { - template - static char test(typename DcLambdaTypes::Ptr); - template - static int test(...); - static constexpr bool value = (sizeof(test(declval())) == 1); - }; + template + static char dc_func_test(typename DcLambdaTypes::Ptr); + template + static int dc_func_test(...); - template::value> + template + constexpr bool DcFuncTest = (sizeof(dc_func_test(declval())) == 1); + + template> struct DcFuncTypeObjBase { using Type = typename DcLambdaTypes::Obj; }; diff --git a/ostd/internal/hashtable.hh b/ostd/internal/hashtable.hh index 97034e0..4792c84 100644 --- a/ostd/internal/hashtable.hh +++ b/ostd/internal/hashtable.hh @@ -130,17 +130,12 @@ namespace detail { static constexpr Size CHUNK_LOWER_BOUND = 32; static constexpr Size CHUNK_UPPER_BOUND = 128; - template - struct HashChainAlign { - static constexpr Size csize = sizeof(HashChain[N]) + sizeof(void *); - static constexpr Size value = ((csize % CACHE_LINE_SIZE) == 0) - ? N : HashChainAlign::value; - }; + template constexpr Size HashChainAlign + = (((sizeof(HashChain[N]) + sizeof(void *)) % CACHE_LINE_SIZE) == 0) + ? N : HashChainAlign; template - struct HashChainAlign { - static constexpr Size value = CHUNK_UPPER_BOUND; - }; + constexpr Size HashChainAlign = CHUNK_UPPER_BOUND; template struct HashChainPad; @@ -156,7 +151,7 @@ namespace detail { template struct HashPad: HashChainPad {}; - template::value, + template, bool P = (V == CHUNK_UPPER_BOUND) > struct HashChunk; diff --git a/ostd/range.hh b/ostd/range.hh index 425ade1..150cb98 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -53,19 +53,17 @@ OSTD_RANGE_TRAIT(Difference) #undef OSTD_RANGE_TRAIT namespace detail { - template - struct IsRangeTest { - template static char test(typename U::Category *, - typename U::Size *, - typename U::Difference *, - typename U::Value *, - RemoveReference< - typename U::Reference - > *); - template static int test(...); - static constexpr bool value - = (sizeof(test(0, 0, 0, 0, 0)) == sizeof(char)); - }; + template static char is_range_test(typename U::Category *, + typename U::Size *, + typename U::Difference *, + typename U::Value *, + RemoveReference< + typename U::Reference + > *); + template static int is_range_test(...); + + template constexpr bool IsRangeTest + = (sizeof(is_range_test(0, 0, 0, 0, 0)) == sizeof(char)); } // is input range @@ -74,7 +72,7 @@ namespace detail { template constexpr bool IsInputRangeCore = IsConvertible, InputRangeTag>; - template::value> + template> constexpr bool IsInputRangeBase = false; template @@ -90,7 +88,7 @@ namespace detail { template constexpr bool IsForwardRangeCore = IsConvertible, ForwardRangeTag>; - template::value> + template> constexpr bool IsForwardRangeBase = false; template @@ -106,7 +104,7 @@ namespace detail { template constexpr bool IsBidirectionalRangeCore = IsConvertible, BidirectionalRangeTag>; - template::value> + template> constexpr bool IsBidirectionalRangeBase = false; template @@ -123,7 +121,7 @@ namespace detail { template constexpr bool IsRandomAccessRangeCore = IsConvertible, RandomAccessRangeTag>; - template::value> + template> constexpr bool IsRandomAccessRangeBase = false; template @@ -140,7 +138,7 @@ namespace detail { template constexpr bool IsFiniteRandomAccessRangeCore = IsConvertible, FiniteRandomAccessRangeTag>; - template::value> + template> constexpr bool IsFiniteRandomAccessRangeBase = false; template @@ -162,7 +160,7 @@ namespace detail { template constexpr bool IsContiguousRangeCore = IsConvertible, ContiguousRangeTag>; - template::value> + template> constexpr bool IsContiguousRangeBase = false; template @@ -191,7 +189,7 @@ namespace detail { detail::OutputRangeTest &&>::value || detail::OutputRangeTest >::value)); - template::value> + template> constexpr bool IsOutputRangeBase = false; template diff --git a/ostd/utility.hh b/ostd/utility.hh index d6d2315..407287a 100644 --- a/ostd/utility.hh +++ b/ostd/utility.hh @@ -262,29 +262,29 @@ namespace detail { template, RemoveCv>, bool = IsEmpty, bool = IsEmpty - > struct CompressedPairSwitch; + > constexpr Size CompressedPairSwitch = detail::Undefined(); /* neither empty */ template - struct CompressedPairSwitch { enum { value = 0 }; }; + constexpr Size CompressedPairSwitch = 0; /* first empty */ template - struct CompressedPairSwitch { enum { value = 1 }; }; + constexpr Size CompressedPairSwitch = 1; /* second empty */ template - struct CompressedPairSwitch { enum { value = 2 }; }; + constexpr Size CompressedPairSwitch = 2; /* both empty, not the same */ template - struct CompressedPairSwitch { enum { value = 3 }; }; + constexpr Size CompressedPairSwitch = 3; /* both empty and same */ template - struct CompressedPairSwitch { enum { value = 1 }; }; + constexpr Size CompressedPairSwitch = 1; - template::value> + template> struct CompressedPairBase; template