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

Will Hawkins via libcxx-commits libcxx-commits at lists.llvm.org
Tue Jan 2 19:23:59 PST 2024


================
@@ -0,0 +1,372 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// constexpr __iterator(__iterator<!_Const> __i)
+//    requires _Const && convertible_to<ranges::iterator_t<_View>, iterator_t<_Base>> &&
+//                 convertible_to<sentinel_t<_View>, sentinel_t<_Base>>
+
+#include <ranges>
+
+#include "../types.h"
+#include "test_iterators.h"
+
+struct NotSimpleViewIterBegin : InputIterBase<NotSimpleViewIterBegin> {};
+
+template <bool CopyConvertible, bool MoveConvertible>
+struct NotSimpleViewConstIterBegin : InputIterBase<NotSimpleViewConstIterBegin<CopyConvertible, MoveConvertible>> {
+  constexpr NotSimpleViewConstIterBegin() = default;
+  constexpr NotSimpleViewConstIterBegin(NotSimpleViewConstIterBegin&&) {}
+  constexpr NotSimpleViewConstIterBegin& operator=(const NotSimpleViewConstIterBegin&) {}
+  constexpr NotSimpleViewConstIterBegin& operator=(NotSimpleViewConstIterBegin&&) {}
+
+  constexpr NotSimpleViewConstIterBegin(const NotSimpleViewConstIterBegin&) {}
+  constexpr NotSimpleViewConstIterBegin(const NotSimpleViewIterBegin&)
+    requires CopyConvertible
+  {}
+  constexpr NotSimpleViewConstIterBegin(NotSimpleViewIterBegin&&)
+    requires MoveConvertible
+  {}
+};
+
+struct NotSimpleViewIterEnd : InputIterBase<NotSimpleViewIterEnd> {};
+
+template <bool CopyConvertible, bool MoveConvertible>
+struct NotSimpleViewConstIterEnd : InputIterBase<NotSimpleViewConstIterEnd<CopyConvertible, MoveConvertible>> {
+  constexpr NotSimpleViewConstIterEnd() = default;
+  constexpr NotSimpleViewConstIterEnd(NotSimpleViewConstIterEnd&&) {}
+  constexpr NotSimpleViewConstIterEnd& operator=(const NotSimpleViewConstIterEnd&) {}
+  constexpr NotSimpleViewConstIterEnd& operator=(NotSimpleViewConstIterEnd&&) {}
+
+  constexpr NotSimpleViewConstIterEnd(const NotSimpleViewConstIterEnd&) {}
+  constexpr NotSimpleViewConstIterEnd(const NotSimpleViewIterEnd&)
+    requires CopyConvertible
+  {}
+  constexpr NotSimpleViewConstIterEnd(NotSimpleViewIterEnd&&)
+    requires MoveConvertible
+  {}
+};
+
+constexpr bool operator==(const NotSimpleViewIterBegin&, const NotSimpleViewIterEnd&) { return true; }
+constexpr bool operator==(const NotSimpleViewIterEnd&, const NotSimpleViewIterBegin&) { return true; }
+
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewConstIterBegin<CopyConvertible, MoveConvertible>&, const NotSimpleViewIterEnd&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewConstIterBegin<CopyConvertible, MoveConvertible>&, const NotSimpleViewIterBegin&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewIterBegin&, const NotSimpleViewConstIterEnd<CopyConvertible, MoveConvertible>&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewIterBegin&, const NotSimpleViewConstIterBegin<CopyConvertible, MoveConvertible>&) {
+  return true;
+}
+
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewConstIterEnd<CopyConvertible, MoveConvertible>&, const NotSimpleViewIterEnd&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewConstIterEnd<CopyConvertible, MoveConvertible>&, const NotSimpleViewIterBegin&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewIterEnd&, const NotSimpleViewConstIterBegin<CopyConvertible, MoveConvertible>&) {
+  return true;
+}
+template <bool CopyConvertible, bool MoveConvertible>
+constexpr bool
+operator==(const NotSimpleViewIterEnd&, const NotSimpleViewConstIterEnd<CopyConvertible, MoveConvertible>&) {
+  return true;
+}
----------------
hawkinsw wrote:

Thanks! (3112b3d058c63568ce03a7fa5f3537124a40d7c4)

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


More information about the libcxx-commits mailing list