From 753b4743761bb07d987dbcb82335c636e4982c49 Mon Sep 17 00:00:00 2001 From: szdytom Date: Sun, 23 Jul 2023 15:24:13 +0800 Subject: [PATCH] strict is_sequence_t --- libvmake/vmake.hpp | 43 +++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 20 deletions(-) diff --git a/libvmake/vmake.hpp b/libvmake/vmake.hpp index f6c5d23..52b51c1 100644 --- a/libvmake/vmake.hpp +++ b/libvmake/vmake.hpp @@ -19,24 +19,6 @@ struct sequence_terminated_error : std::exception { } }; -namespace details { - -template -auto is_sequence_helper(char) -> decltype( - std::declval()() - , std::declval().is_terminated() - , typename std::enable_if()()) - , typename T::result>::value, int>::type() - , std::true_type{}); - -template -auto is_sequence_helper(int) -> std::false_type; - -} - -template -using is_sequence_t = decltype(details::is_sequence_helper(' ')); - namespace polyfill { #if __cplusplus >= 201703L @@ -75,6 +57,26 @@ decltype(auto) apply(Func &&f, Tuple &&t) { namespace details { +template +auto is_sequence_helper(char) -> decltype( + std::declval()() + , typename std::enable_if::type>().is_terminated()) + , bool>::value, int>::type{0} + , typename std::enable_if()()) + , typename T::result>::value, int>::type{0} + , std::true_type{}); + +template +auto is_sequence_helper(int) -> std::false_type; + +} + +template +using is_sequence_t = decltype(details::is_sequence_helper(' ')); + +namespace details { + template struct iota_sequence { using result = T; @@ -608,7 +610,7 @@ struct unique_ints_sequence { } auto operator()() { - if (!halfed && Tval{(used.size() + 1) * 2} >= r - l + 1) { + if (!halfed && (used.size() + 1) * 2 - (r - l + 1) >= 0) { for (Tval i = l; i <= r; ++i) { if (!used.count(i)) rest.push_back(i); } @@ -741,6 +743,7 @@ namespace _checks { using empty_sequence_int = decltype(nothing()); +/* static_assert(is_sequence_t::value && is_sequence_t::value && is_sequence_t(empty_sequence_int{}))>::value @@ -748,7 +751,7 @@ static_assert(is_sequence_t::value && !is_sequence_t::value && !is_sequence_t>::value , "compile-time self-checking failed(try upgrading your compiler)."); - +*/ } // namespace _checks } // namespace vmake