ranges: add izip helper

This commit is contained in:
Danny Robson 2024-10-29 14:02:10 +10:00
parent ffa09a50a0
commit b2e36f4e0f
2 changed files with 19 additions and 0 deletions

View File

@ -546,6 +546,7 @@ list (
range.hpp
ranges/chunk.hpp
ranges/enumerate.hpp
ranges/izip.hpp
rational.cpp
rational.hpp
region.cpp

View File

@ -0,0 +1,18 @@
#pragma once
#include <ranges>
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> (rs)...
);
}
}