[libcxx-commits] [libcxx] [libc++][ranges] P2164R9: Implements `views::enumerate` (PR #73617)

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Sun Mar 16 10:21:02 PDT 2025


================
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// <ranges>
+
+// class enumerate_view
+
+// class enumerate_view::iterator
+
+// constexpr const iterator_t<Base>& base() const & noexcept;
+// constexpr iterator_t<Base> base() &&;
+
+#include <array>
+#include <cassert>
+#include <concepts>
+#include <ranges>
+#include <utility>
+#include <tuple>
+
+#include "test_iterators.h"
+#include "../types.h"
+
+template <class Iterator>
+constexpr void testBase() {
+  using Sentinel          = sentinel_wrapper<Iterator>;
+  using View              = MinimalView<Iterator, Sentinel>;
+  using EnumerateView     = std::ranges::enumerate_view<View>;
+  using EnumerateIterator = std::ranges::iterator_t<EnumerateView>;
+
+  auto make_enumerate_view = [](auto begin, auto end) {
+    View view{Iterator(begin), Sentinel(Iterator(end))};
----------------
frederick-vs-ja wrote:

```suggestion
    View view{Iterator(std::to_address(begin)), Sentinel(Iterator(std::to_address(end)))};
```

Ditto for other constructions of `Iterator`.

https://github.com/llvm/llvm-project/pull/73617


More information about the libcxx-commits mailing list