ranges: add a simplistic implementation of enumerate
This is a temporary workaround because clang lacks it.
This commit is contained in:
parent
ec2f801357
commit
ffa09a50a0
@ -545,6 +545,7 @@ list (
|
|||||||
range.cpp
|
range.cpp
|
||||||
range.hpp
|
range.hpp
|
||||||
ranges/chunk.hpp
|
ranges/chunk.hpp
|
||||||
|
ranges/enumerate.hpp
|
||||||
rational.cpp
|
rational.cpp
|
||||||
rational.hpp
|
rational.hpp
|
||||||
region.cpp
|
region.cpp
|
||||||
|
19
cruft/util/ranges/enumerate.hpp
Normal file
19
cruft/util/ranges/enumerate.hpp
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <ranges>
|
||||||
|
|
||||||
|
namespace cruft::util::ranges {
|
||||||
|
/// A very simple implementation of std::views::enumerate provided because clang-19 lacks it
|
||||||
|
///
|
||||||
|
/// clang#19: check me again in clang-20
|
||||||
|
template <typename Rng>
|
||||||
|
requires (std::ranges::input_range<Rng>)
|
||||||
|
auto
|
||||||
|
enumerate (Rng &&r)
|
||||||
|
{
|
||||||
|
return std::views::zip (
|
||||||
|
std::views::iota (0),
|
||||||
|
std::forward<Rng> (r)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user