ranges: add izip helper
This commit is contained in:
parent
ffa09a50a0
commit
b2e36f4e0f
@ -546,6 +546,7 @@ list (
|
||||
range.hpp
|
||||
ranges/chunk.hpp
|
||||
ranges/enumerate.hpp
|
||||
ranges/izip.hpp
|
||||
rational.cpp
|
||||
rational.hpp
|
||||
region.cpp
|
||||
|
18
cruft/util/ranges/izip.hpp
Normal file
18
cruft/util/ranges/izip.hpp
Normal 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)...
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user