From 024dbaf525a19f25e1d968783280d6f62b807e36 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Tue, 11 Jun 2024 07:57:56 +0000 Subject: [PATCH] Add PackConstexprWrapper --- include/utempl/utils.hpp | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index 56ae4fe..ba965ee 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -20,6 +20,10 @@ struct Wrapper { }; }; +template +inline constexpr Wrapper kWrapper; + + template consteval auto ParseNumber() -> T { T response{}; @@ -334,7 +338,7 @@ inline constexpr auto Map(Tuple&& tuple, F&& f, TypeList result = {}) { template inline constexpr auto Map(F&& f, TypeList result = {}) { - return [f = std::forward(f), result](Tuple&& tuple){ + return [f = std::forward(f), result](Tuple&& tuple) { if constexpr(!std::is_same_v) { return Map(std::forward(tuple), std::move(f), result); } else { @@ -343,15 +347,23 @@ inline constexpr auto Map(F&& f, TypeList result = {}) { }; }; +template +consteval auto PackConstexprWrapper() { + return [&](std::index_sequence) { + return MakeTuple(kWrapper(Tuple)>...); + }(std::make_index_sequence>()); +}; + + template inline constexpr auto Reverse(Tuple&& tuple) { - return [&](std::index_sequence) { + return [&](std::index_sequence) { return MakeTuple(Get - Is - 1>(std::forward(tuple))...); }(std::make_index_sequence>()); }; consteval auto Reverse() { - return [](Tuple&& tuple){ + return [](Tuple&& tuple) { return Reverse(std::forward(tuple)); }; };