From 16ea7cfc4d834a3c0cedb4a833ff0f212eeee2dc Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Wed, 6 Aug 2025 18:37:49 +0200 Subject: Fixing math operators --- modules/codec/c++/iterator.hpp | 55 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 modules/codec/c++/iterator.hpp (limited to 'modules/codec/c++/iterator.hpp') diff --git a/modules/codec/c++/iterator.hpp b/modules/codec/c++/iterator.hpp new file mode 100644 index 0000000..96a4441 --- /dev/null +++ b/modules/codec/c++/iterator.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include "data.hpp" + +namespace saw { +namespace impl { +template +struct iterator_index_parameter_value { + static_assert(i > 0, "Shouldn't happen"); + static constexpr uint64_t value = iterator_index_parameter_value::value; +}; + +template +struct iterator_index_parameter_value<0u, val_0, vals...> { + static constexpr uint64_t value = val_0; +}; + +template +struct iterator_in_bounds { +private: + static constexpr std::array dims_{Dims...}; + + template + static error_or apply_i(Func& func, data, encode::Native>& index){ + if constexpr (level >= sizeof...(Dims)){ + return func(index); + }else{ + index.at({level}).set(0); + + for(;index.at({level}) < impl::iterator_index_parameter_value::value; ++index.at({level})){ + auto eov = apply_i(func, index); + if(eov.is_error()){ + return eov; + } + } + } + return saw::make_void(); + } +public: + static error_or apply(Func& func){ + data, encode::Native> index; + return apply_i<0u>(func, index); + } +}; +} + +template +struct rank_iterator { + template + static error_or in_fixed_bounds(Func&& func){ + // static_assert(D == 2u, "Currently a lazy implementation for AND combinations of intervalls."); + return impl::iterator_in_bounds::apply(func); + } +}; +} -- cgit v1.2.3