From f07d63bd67baf150bbb44cb87c1cdb2252b447f4 Mon Sep 17 00:00:00 2001 From: sha512sum Date: Fri, 1 Mar 2024 16:50:49 +0000 Subject: [PATCH] Add ForEach --- include/utempl/utils.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/utempl/utils.hpp b/include/utempl/utils.hpp index 004d903..fbc4e55 100644 --- a/include/utempl/utils.hpp +++ b/include/utempl/utils.hpp @@ -267,6 +267,14 @@ inline constexpr auto Filter(Tuple&& tuple, auto&& f) { ); }; +template +inline constexpr auto ForEach(Tuple&& tuple, auto&& f) { + [&](std::index_sequence){ + (f(Get(std::forward(tuple))), ...); + }(std::make_index_sequence>()); +}; + + template struct Curryer { F f;