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

A. Jiang via libcxx-commits libcxx-commits at lists.llvm.org
Wed Mar 5 19:22:45 PST 2025


================
@@ -0,0 +1,134 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_ENUMERATE_TYPES_H
+#define TEST_STD_RANGES_RANGE_ADAPTORS_RANGE_ENUMERATE_TYPES_H
+
+#include <cstddef>
+#include <ranges>
+#include <tuple>
+
+#include "test_iterators.h"
+#include "test_macros.h"
+
+// Types
+
+template <typename T, typename DifferenceT = std::ptrdiff_t>
+using ValueType = std::tuple<DifferenceT, T>;
+
+struct RangeView : std::ranges::view_base {
+  using Iterator = cpp20_input_iterator<int*>;
+  using Sentinel = sentinel_wrapper<Iterator>;
+
+  constexpr explicit RangeView(int* b, int* e) : begin_(b), end_(e) {}
----------------
frederick-vs-ja wrote:

Some iterator types are different in hardening modes.

```suggestion
  template <std::contiguous_iterator It>
    requires std::same_as<std::iter_value_t<It>, int>
  constexpr explicit RangeView(It b, It e) : begin_(std::to_address(b)), end_(std::to_address(e)) {}
```

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


More information about the libcxx-commits mailing list