From d3602dc2dd07effb1ceba76589b3129d9fd1027f Mon Sep 17 00:00:00 2001 From: sha512sum Date: Thu, 29 Feb 2024 22:51:00 +0000 Subject: [PATCH] Forward tuple to Get (it's safe, there's a check) --- include/utempl/utils.hpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index c42c9c9..0bfcc66 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -36,9 +36,9 @@ consteval auto operator"" _c() { } // namespace literals template -inline constexpr auto Arg(Ts&&... args) requires (I < sizeof...(Ts)) { - return [&](std::index_sequence){ - return [](decltype(Caster(Is))..., auto&& response, ...){ +inline constexpr auto Arg(Ts&&... args) -> decltype(auto) requires (I < sizeof...(Ts)) { + return [&](std::index_sequence) -> decltype(auto) { + return [](decltype(Caster(Is))..., auto&& response, ...) -> decltype(auto) { return response; }(std::forward(args)...); }(std::make_index_sequence()); @@ -140,14 +140,14 @@ concept IsTypeList = Overloaded( template inline constexpr auto Transform(Tuple&& container, auto&& f) { return [&](std::index_sequence){ - return MakeTuple(f(Get(container))...); + return MakeTuple(f(Get(std::forward(container)))...); }(std::make_index_sequence>()); }; template inline constexpr auto Reverse(Tuple&& tuple) { return [&](std::index_sequence) { - return MakeTuple(Get - Is - 1>(tuple)...); + return MakeTuple(Get - Is - 1>(std::forward(tuple))...); }(std::make_index_sequence>()); }; @@ -183,7 +183,7 @@ inline constexpr auto LeftFold(Tuple&& tuple, T&& init, F&& f) { return ( impl::LeftFold, std::remove_cvref_t>{.data = std::forward(init), .f = std::forward(f)} | ... - | impl::LeftFold(tuple))>>{.data = Get(tuple)} + | impl::LeftFold(std::forward(tuple)))>>{.data = Get(std::forward(tuple))} ).data; }(std::make_index_sequence>()); }; @@ -193,7 +193,7 @@ inline constexpr auto LeftFold(Tuple&& tuple, T&& init, F&& f) { template inline constexpr auto TupleCat(Tuple&& tuple, Tuple2&& tuple2) { return [&](std::index_sequence, std::index_sequence){ - return MakeTuple(Get(tuple)..., Get(tuple2)...); + return MakeTuple(Get(std::forward(tuple))..., Get(std::forward(tuple2))...); }(std::make_index_sequence>(), std::make_index_sequence>()); };