[libcxx-commits] [libcxx] [libc++][ranges] Applied [[nodiscard]] to `adjacent_transform_view` (PR #205900)
Hristo Hristov via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Jun 30 03:53:39 PDT 2026
================
@@ -0,0 +1,93 @@
+
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// REQUIRES: std-at-least-c++23
+
+// Test the libc++ extension that std::ranges::adjacent_transform_view and std::views::adjacent_transform are marked as [[nodiscard]].
+
+#include <ranges>
+#include <utility>
+#include <functional>
+
+struct View : std::ranges::view_interface<View> {
+ int* begin();
+ const int* begin() const;
+ volatile int* end();
+ const volatile int* end() const;
+};
+static_assert(!std::ranges::common_range<View>);
+static_assert(!std::same_as<std::ranges::iterator_t<View>, std::ranges::iterator_t<const View>>);
+static_assert(!std::same_as<std::ranges::sentinel_t<View>, std::ranges::sentinel_t<const View>>);
+
+void test() {
+ int range[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
----------------
Zingam wrote:
Can you also move this range down there where you use it actually?
Or: doesn't a `View range;` suffice to test the adjacent_transform CPOs?
https://github.com/llvm/llvm-project/pull/205900
More information about the libcxx-commits
mailing list