From 11b2c88058f6df66b7249008f733dd6311b4b705 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Tue, 5 May 2026 14:48:23 -0500 Subject: [PATCH 1/2] sub_visit.hpp added --- include/beman/execution/detail/sub_visit.hpp | 44 ++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 include/beman/execution/detail/sub_visit.hpp diff --git a/include/beman/execution/detail/sub_visit.hpp b/include/beman/execution/detail/sub_visit.hpp new file mode 100644 index 00000000..a527bfd4 --- /dev/null +++ b/include/beman/execution/detail/sub_visit.hpp @@ -0,0 +1,44 @@ +// include/beman/execution/detail/sub_visit.hpp -*-C++-*- +// ---------------------------------------------------------------------------- +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// ---------------------------------------------------------------------------- + +#ifndef INCLUDED_BEMAN_EXECUTION_DETAIL_SUB_VISIT +#define INCLUDED_BEMAN_EXECUTION_DETAIL_SUB_VISIT + +#include +#include +#include + +// ---------------------------------------------------------------------------- + +namespace beman::execution::detail { +/* + * \brief Helper function creatig thunks for a variant visit. + * \headerfile beman/execution/task.hpp + * \internal + */ +template +void sub_visit_thunks(Fun& fun, Var& var, std::index_sequence) { + using thunk_t = void (*)(Fun&, Var&); + static constexpr thunk_t thunks[]{(+[](Fun& f, Var& v) { f(std::get(v)); })...}; + thunks[var.index() - Start](fun, var); +} + +/* + * \brief Helper function visiting a suffix of variant options + * \headerfile beman/execution/task.hpp + * \internal + */ +template +void sub_visit(auto&& fun, std::variant& v) { + if (v.index() < Start) + return; + sub_visit_thunks(fun, v, std::make_index_sequence{}); +} + +} // namespace beman::execution::detail + +// ---------------------------------------------------------------------------- + +#endif \ No newline at end of file From 5940a2692c012be16e2773f33e464f5ab742d377 Mon Sep 17 00:00:00 2001 From: JorgeV92 Date: Tue, 5 May 2026 15:45:35 -0500 Subject: [PATCH 2/2] fix new line --- include/beman/execution/detail/sub_visit.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/beman/execution/detail/sub_visit.hpp b/include/beman/execution/detail/sub_visit.hpp index a527bfd4..19b9cb59 100644 --- a/include/beman/execution/detail/sub_visit.hpp +++ b/include/beman/execution/detail/sub_visit.hpp @@ -41,4 +41,4 @@ void sub_visit(auto&& fun, std::variant& v) { // ---------------------------------------------------------------------------- -#endif \ No newline at end of file +#endif