libcruft-util/cruft/util/ranges/enumerate.hpp
Danny Robson ffa09a50a0 ranges: add a simplistic implementation of enumerate
This is a temporary workaround because clang lacks it.
2024-10-17 09:08:19 +10:00

20 lines
447 B
C++

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