[libcxx-commits] [libcxx] [libc++][ranges] Implement `ranges::stride_view`. (PR #65200)
Konstantin Varlamov via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 13 23:40:56 PST 2023
================
@@ -0,0 +1,32 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// std::views::stride_view
+
+#include "test.h"
+#include <ranges>
+#include <type_traits>
+#include <utility>
+
+constexpr bool test() {
+ static_assert(noexcept(std::declval<std::ranges::stride_view<BidirArrayView<int>>>().stride()));
----------------
var-const wrote:
We need to make sure that `stride()` returns the same value that we passed in the constructor, and also that for a default-constructed `stride_view`, `stride` returns `0`.
(For tests that only contain `static_assert`s, it's better to write a `verify.cpp` test (as opposed to `pass.cpp`). Those tests are never run, only compiled. However, this test should actually contain runtime checks as described above, so it should stay a `pass.cpp` test)
https://github.com/llvm/llvm-project/pull/65200
More information about the libcxx-commits
mailing list