diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index 7b863bd..1dc6c1e 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -23,6 +23,24 @@ struct Wrapper { template inline constexpr Wrapper kWrapper; +namespace impl { + +template +struct kSeq {}; + +} // namespace impl + +template +inline constexpr impl::kSeq kSeq; + +template +constexpr auto operator|(F&& f, impl::kSeq) { + return [&](std::index_sequence){ + return std::forward(f)(kWrapper...); + }(std::make_index_sequence()); +}; + + template consteval auto ParseNumber() -> T { @@ -300,9 +318,9 @@ inline constexpr auto operator|(Tuple&& tuple, FF&& f) { template inline constexpr auto Unpack(Tuple&& tuple, F&& f) -> decltype(auto) { - return [&](std::index_sequence) -> decltype(auto) { - return f(Get(std::forward(tuple))...); - }(std::make_index_sequence>()); + return [&](auto... is) -> decltype(auto) { + return f(Get(std::forward(tuple))...); + } | kSeq>; }; template @@ -450,10 +468,9 @@ inline constexpr auto Tie(Ts&... args) -> Tuple { }; template