libcruft-util/cruft/util/ranges/izip.hpp

19 lines
447 B
C++
Raw Normal View History

2024-10-29 15:02:10 +11:00
#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)...
);
}
}