diff --git a/cruft/util/CMakeLists.txt b/cruft/util/CMakeLists.txt index e799a912..815a920c 100644 --- a/cruft/util/CMakeLists.txt +++ b/cruft/util/CMakeLists.txt @@ -546,6 +546,7 @@ list ( range.hpp ranges/chunk.hpp ranges/enumerate.hpp + ranges/izip.hpp rational.cpp rational.hpp region.cpp diff --git a/cruft/util/ranges/izip.hpp b/cruft/util/ranges/izip.hpp new file mode 100644 index 00000000..d2a15cf4 --- /dev/null +++ b/cruft/util/ranges/izip.hpp @@ -0,0 +1,18 @@ +#pragma once + +#include + + +namespace cruft::ranges { + /// A convenience function that combines enumerate and zip, such that a preceding index element is returned in + // the result tuple. + template <::std::ranges::viewable_range... Rs> + constexpr ::std::ranges::view auto + izip (Rs &&...rs) + { + return ::std::views::zip ( + ::std::views::iota (0), + ::std::forward (rs)... + ); + } +}