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

20 lines
447 B
C++
Raw Normal View History

#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)
);
}
}