diff options
| author | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-05-21 15:00:31 +0200 |
|---|---|---|
| committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2026-05-21 15:00:31 +0200 |
| commit | 3b60c30226695421df2521c11a45177ff9b4086b (patch) | |
| tree | ea7c01818300a2dea17a31b979540f7aa2e3b937 /lib/core/c++/iterator.hpp | |
| parent | 22c8f0540533c2d77201e90cdcd3dc30524a89e4 (diff) | |
| parent | b5d8593b9a2f0f58cb228444dcd09a2c5002e039 (diff) | |
| download | libs-lbm-3b60c30226695421df2521c11a45177ff9b4086b.tar.gz | |
Merge branch 'dev'
Diffstat (limited to 'lib/core/c++/iterator.hpp')
| -rw-r--r-- | lib/core/c++/iterator.hpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/lib/core/c++/iterator.hpp b/lib/core/c++/iterator.hpp index 866543a..7fd6f58 100644 --- a/lib/core/c++/iterator.hpp +++ b/lib/core/c++/iterator.hpp @@ -50,6 +50,37 @@ public: } }; +template<typename Tupl> +struct ct_tuple_iterator; + +template<typename... Tup> +struct ct_tuple_iterator<sch::Tuple<Tup...>> final { +private: + template<typename Func, uint64_t i> + static constexpr saw::error_or<void> apply_i( + Func& func, + saw::data<sch::Tuple<Tup...>>& tup + ){ + if constexpr ( i < sizeof...(Tup) ){ + auto eov = func(tup.template get<i>()); + if(eov.is_error()){ + return eov; + } + return apply_i<Func,i+1u>(func,tup); + } + + return saw::make_void(); + } +public: + template<typename Func> + static constexpr saw::error_or<void> apply( + Func&& func, + saw::data<sch::Tuple<Tup...>>& tup + ){ + return apply_i<Func,0u>(func,tup); + } +}; + /* Ambiguous template<typename Func> void iterate_over(Func&& func, const saw::data<sch::FixedArray<sch::UInt64,3u>>& start, const saw::data<sch::FixedArray<sch::UInt64,3u>>& end, const saw::data<sch::FixedArray<sch::UInt64,3u>>& dist = {{{0u,0u,0u}}}){ |
