diff --git a/cruft/util/CMakeLists.txt b/cruft/util/CMakeLists.txt index 94c8d0a7..e799a912 100644 --- a/cruft/util/CMakeLists.txt +++ b/cruft/util/CMakeLists.txt @@ -545,6 +545,7 @@ list ( range.cpp range.hpp ranges/chunk.hpp + ranges/enumerate.hpp rational.cpp rational.hpp region.cpp diff --git a/cruft/util/ranges/enumerate.hpp b/cruft/util/ranges/enumerate.hpp new file mode 100644 index 00000000..a1b6d58e --- /dev/null +++ b/cruft/util/ranges/enumerate.hpp @@ -0,0 +1,19 @@ +#pragma once + +#include + +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 + requires (std::ranges::input_range) + auto + enumerate (Rng &&r) + { + return std::views::zip ( + std::views::iota (0), + std::forward (r) + ); + } +}