[libcxx-commits] [libcxx] [libc++][ranges] Implement P1899 `ranges::stride_view`. (PR #65200)

Hristo Hristov via libcxx-commits libcxx-commits at lists.llvm.org
Mon Feb 23 22:48:39 PST 2026


================
@@ -0,0 +1,73 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 that
+// std::view::stride()
+// std::ranges::stride_view::base()
+// std::ranges::stride_view::begin()
+// std::ranges::stride_view::end()
+// std::ranges::stride_view::size()
+// std::ranges::stride_view::stride()
+// are all marked nodiscard.
+
+#include <ranges>
+
+#include "../../../../std/ranges/range.adaptors/range.stride.view/types.h"
----------------
H-G-Hristov wrote:

For these kinds of tests `[[nodiscard]]` I think that is is OK and preferable if you make them self-contained. That way the reviewer won't need to jump around the source files to look for the types,. You only need to declare minimal types to verify the presence of the  `[[nodiscard]]` attribute. This is how I did for most of the `[[nodiscard]]` tests so far. 
Also please make sure to test every case where you have applied `[[nodiscard]]` and to apply it according to: 
https://libcxx.llvm.org/CodingGuidelines.html#apply-nodiscard-where-relevant


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


More information about the libcxx-commits mailing list