diff --git a/ostd/algorithm.hh b/ostd/algorithm.hh index 2135aaa..c827e63 100644 --- a/ostd/algorithm.hh +++ b/ostd/algorithm.hh @@ -849,7 +849,9 @@ public: namespace detail { template - using MapReturnType = decltype(declval()(declval>())); + using MapReturnType = decltype( + std::declval()(std::declval>()) + ); } template @@ -928,9 +930,9 @@ public: namespace detail { template - using FilterPred = EnableIf< - IsSame()(declval>())), bool>, P - >; + using FilterPred = EnableIf()(std::declval>())), bool + >, P>; } template diff --git a/ostd/format.hh b/ostd/format.hh index 486e9d5..446b534 100644 --- a/ostd/format.hh +++ b/ostd/format.hh @@ -438,9 +438,9 @@ protected: template< typename T, typename R, typename = EnableIf< - IsSame() - .to_format(declval(), declval())), bool - > + IsSame().to_format( + std::declval(), std::declval() + )), bool> > > inline bool to_format(T const &v, R &writer, FormatSpec const &fs) { @@ -615,7 +615,7 @@ namespace detail { } template - static True test_fmt_tostr(decltype(ostd::to_string(declval())) *); + static True test_fmt_tostr(decltype(ostd::to_string(std::declval())) *); template static False test_fmt_tostr(...); @@ -662,7 +662,8 @@ namespace detail { template static True test_tofmt(decltype(to_format( - declval(), declval(), declval() + std::declval(), std::declval(), + std::declval() )) *); template diff --git a/ostd/keyset.hh b/ostd/keyset.hh index cade171..73aebe0 100644 --- a/ostd/keyset.hh +++ b/ostd/keyset.hh @@ -19,7 +19,7 @@ namespace ostd { namespace detail { template - using KeysetKeyRet = decltype(declval().get_key()); + using KeysetKeyRet = decltype(std::declval().get_key()); template using KeysetKey = Decay> const; diff --git a/ostd/memory.hh b/ostd/memory.hh index 5883623..dd26bf1 100644 --- a/ostd/memory.hh +++ b/ostd/memory.hh @@ -533,7 +533,7 @@ namespace detail { constexpr bool AllocateHintTest = IsSame< decltype(allocate_hint_test( - declval(), declval(), declval() + std::declval(), std::declval(), std::declval() )), True >; @@ -586,7 +586,7 @@ namespace detail { constexpr bool ConstructTest = IsSame< decltype(construct_test( - declval(), declval(), declval()... + std::declval(), std::declval(), std::declval()... )), True >; @@ -619,8 +619,9 @@ namespace detail { auto destroy_test(A const &, P &&) -> False; template - constexpr bool DestroyTest = - IsSame(), declval

())), True>; + constexpr bool DestroyTest = IsSame< + decltype(destroy_test(std::declval(), std::declval

())), True + >; template inline void destroy(True, A &a, T *p) { @@ -649,7 +650,7 @@ namespace detail { template constexpr bool AllocMaxSizeTest = - IsSame())), True>; + IsSame())), True>; template inline AllocatorSize alloc_max_size(True, A const &a) { @@ -680,7 +681,7 @@ namespace detail { template constexpr bool AllocCopyTest = - IsSame())), True>; + IsSame())), True>; template inline AllocatorType alloc_container_copy(True, A const &a) { diff --git a/ostd/range.hh b/ostd/range.hh index 0551054..48e64e4 100644 --- a/ostd/range.hh +++ b/ostd/range.hh @@ -756,7 +756,7 @@ struct ranged_traits; namespace detail { template - static True test_direct_iter(decltype(declval().iter()) *); + static True test_direct_iter(decltype(std::declval().iter()) *); template static False test_direct_iter(...); diff --git a/ostd/string.hh b/ostd/string.hh index 5c35420..d6cea5f 100644 --- a/ostd/string.hh +++ b/ostd/string.hh @@ -779,11 +779,11 @@ namespace detail { template static auto test_stringify(int) -> - BoolConstant().stringify()), String>>; + BoolConstant().stringify()), String>>; template - static True test_stringify(decltype(declval().to_string - (declval())) *); + static True test_stringify(decltype(std::declval().to_string + (std::declval())) *); template static False test_stringify(...); @@ -792,7 +792,7 @@ namespace detail { constexpr bool StringifyTest = decltype(test_stringify(0))::value; template - static True test_iterable(decltype(ostd::iter(declval())) *); + static True test_iterable(decltype(ostd::iter(std::declval())) *); template static False test_iterable(...); diff --git a/ostd/type_traits.hh b/ostd/type_traits.hh index 4623b8a..1406ab6 100644 --- a/ostd/type_traits.hh +++ b/ostd/type_traits.hh @@ -10,6 +10,8 @@ #include #include +#include + #include "ostd/types.hh" namespace ostd { @@ -51,11 +53,6 @@ using RemoveReference = typename detail::RemoveReferenceBase::Type; template using RemoveAllExtents = typename detail::RemoveAllExtentsBase::Type; -namespace detail { - template - AddRvalueReference declval_in() noexcept; -} - /* size in bits */ template @@ -613,8 +610,6 @@ constexpr bool HasVirtualDestructor = __has_virtual_destructor(T); /* is constructible */ namespace detail { -#define OSTD_MOVE(v) static_cast &&>(v) - template struct Select2nd { using Type = T; }; @@ -622,18 +617,16 @@ namespace detail { template typename Select2nd< - decltype(OSTD_MOVE(T(declval_in()...))), True + decltype(std::move(T(std::declval()...))), True >::Type is_ctible_test(T &&, A &&...); -#undef OSTD_MOVE - template False is_ctible_test(Any, A &&...); template constexpr bool CtibleCore = CommonTypeBase< - decltype(is_ctible_test(declval_in(), declval_in()...)) + decltype(is_ctible_test(std::declval(), std::declval()...)) >::Type::value; /* function types are not constructible */ @@ -654,7 +647,7 @@ namespace detail { template constexpr bool CtibleCore = CommonTypeBase< - decltype(CtibleRef::test(declval_in())) + decltype(CtibleRef::test(std::declval())) >::Type::value; /* scalars and references are not constructible from multiple args */ @@ -726,14 +719,14 @@ namespace detail { template constexpr bool NothrowCtibleCore = - noexcept(T(declval_in()...)); + noexcept(T(std::declval()...)); template void implicit_conv_to(T) noexcept {} template constexpr bool NothrowCtibleCore = - noexcept(ostd::detail::implicit_conv_to(declval_in())); + noexcept(ostd::detail::implicit_conv_to(std::declval())); template constexpr bool NothrowCtibleCore = false; @@ -767,7 +760,7 @@ constexpr bool IsNothrowMoveConstructible = namespace detail { template typename detail::Select2nd< - decltype((declval_in() = declval_in())), True + decltype((std::declval() = std::declval())), True >::Type assign_test(T &&, U &&); template @@ -775,7 +768,7 @@ namespace detail { template || IsVoid> constexpr bool IsAssignableBase = CommonTypeBase< - decltype(assign_test(declval_in(), declval_in())) + decltype(assign_test(std::declval(), std::declval())) >::Type::value; template @@ -808,7 +801,7 @@ namespace detail { template constexpr bool NothrowAssignableCore = - noexcept(declval_in() = declval_in()); + noexcept(std::declval() = std::declval()); } template constexpr bool IsNothrowAssignable = @@ -835,7 +828,7 @@ namespace detail { template struct IsDestructorWellformed { template static char test(typename IsDtibleApply< - decltype(detail::declval_in().~TT()) + decltype(std::declval().~TT()) >::Type); template @@ -885,7 +878,7 @@ namespace detail { constexpr bool NothrowDtibleCore = false; template - constexpr bool NothrowDtibleCore = noexcept(declval_in().~T()); + constexpr bool NothrowDtibleCore = noexcept(std::declval().~T()); } template @@ -995,7 +988,7 @@ namespace detail { static void test_f(TT); template(declval_in())) + typename = decltype(test_f(std::declval())) > static True test(int); @@ -1456,7 +1449,6 @@ namespace detail { struct InvokeAny { InvokeAny(...); }; -#define OSTD_FWD(T, _v) static_cast(_v) template inline auto func_invoke(InvokeAny, A &&...) -> InvokeNat; @@ -1472,9 +1464,9 @@ namespace detail { > > inline auto func_invoke(F &&f, T &&v, A &&...args) -> - decltype((OSTD_FWD(T, v).*f)(OSTD_FWD(A, args)...)) + decltype((std::forward(v).*f)(std::forward(args)...)) { - return (OSTD_FWD(T, v).*f)(OSTD_FWD(A, args)...); + return (std::forward(v).*f)(std::forward(args)...); } template< @@ -1488,9 +1480,9 @@ namespace detail { > > inline auto func_invoke(F &&f, T &&v, A &&...args) -> - decltype(((*OSTD_FWD(T, v)).*f)(OSTD_FWD(A, args)...)) + decltype(((*std::forward(v)).*f)(std::forward(args)...)) { - return ((*OSTD_FWD(T, v)).*f)(OSTD_FWD(A, args)...); + return ((*std::forward(v)).*f)(std::forward(args)...); } template< @@ -1503,8 +1495,8 @@ namespace detail { > > > - inline auto func_invoke(F &&f, T &&v) -> decltype(OSTD_FWD(T, v).*f) { - return OSTD_FWD(T, v).*f; + inline auto func_invoke(F &&f, T &&v) -> decltype(std::forward(v).*f) { + return std::forward(v).*f; } template< @@ -1517,22 +1509,21 @@ namespace detail { > > > - inline auto func_invoke(F &&f, T &&v) -> decltype((*OSTD_FWD(T, v)).*f) { - return (*OSTD_FWD(T, v)).*f; + inline auto func_invoke(F &&f, T &&v) -> decltype((*std::forward(v)).*f) { + return (*std::forward(v)).*f; } template inline auto func_invoke(F &&f, A &&...args) -> - decltype(OSTD_FWD(F, f)(OSTD_FWD(A, args)...)) + decltype(std::forward(f)(std::forward(args)...)) { - return OSTD_FWD(F, f)(OSTD_FWD(A, args)...); + return std::forward(f)(std::forward(args)...); } -#undef OSTD_FWD template struct FuncInvokableBase { using Type = decltype( - func_invoke(declval_in(), declval_in()...) + func_invoke(std::declval(), std::declval()...) ); static constexpr bool value = !IsSame; }; @@ -1596,7 +1587,7 @@ namespace detail { template struct CommonTypeBase { using Type = Decay(): detail::declval_in() + true ? std::declval(): std::declval() )>; }; diff --git a/ostd/utility.hh b/ostd/utility.hh index c7f8a66..ee6e337 100644 --- a/ostd/utility.hh +++ b/ostd/utility.hh @@ -15,17 +15,13 @@ namespace ostd { -/* declval */ - -template -AddRvalueReference declval() noexcept; - /* swap */ namespace detail { template - auto test_swap(int) -> - BoolConstant().swap(declval()))>>; + auto test_swap(int) -> BoolConstant().swap(std::declval())) + >>; template False test_swap(...);