[libcxx-commits] [libcxx] [libc++][ranges] Implement `ranges::stride_view`. (PR #65200)
Will Hawkins via libcxx-commits
libcxx-commits at lists.llvm.org
Mon Nov 20 07:09:18 PST 2023
================
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 "__ranges/stride_view.h"
+#include "test.h"
+
+// Do not use for execution -- only useful for testing compilation/type conditions.
+template <typename T>
+struct non_input_iterator {
+ struct __invalid_iterator_tag {};
+ using value_type = T;
+ using difference_type = int;
+ using iterator_concept = __invalid_iterator_tag;
+
+ constexpr non_input_iterator& operator++() { return *this; }
+ constexpr void operator++(int) {}
+ constexpr T operator*() const { return T{}; }
+
+ friend constexpr bool operator==(const non_input_iterator&, const non_input_iterator&) { return true; }
+};
+
+template <typename T>
+inline constexpr bool std::ranges::enable_borrowed_range<non_input_iterator<T>> = true;
+
+class almost_input_range : public std::ranges::view_base {
+public:
+ constexpr auto begin() const { return non_input_iterator<int>{}; }
+ constexpr auto end() const { return non_input_iterator<int>{}; }
+};
+
+class non_view_range {
+public:
+ constexpr int* begin() const { return nullptr; }
+ constexpr int* end() const { return nullptr; }
+};
+
+constexpr bool test() {
----------------
hawkinsw wrote:
I believe that this is addressed in 1374fd3e6b29de727000338a5525b86d6e24ce18.
https://github.com/llvm/llvm-project/pull/65200
More information about the libcxx-commits
mailing list