[libcxx-commits] [libcxx] [libc++] Implement `views::join_with` (PR #65536)

via libcxx-commits libcxx-commits at lists.llvm.org
Thu Dec 26 07:20:16 PST 2024


================
@@ -0,0 +1,256 @@
+//===----------------------------------------------------------------------===//
+//
+// 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>
+
+// friend constexpr bool operator==(const iterator& x, const iterator& y)
+//   requires ref-is-glvalue && forward_range<Base> &&
+//            equality_comparable<InnerIter>;
+
+#include <ranges>
+
+#include <array>
+#include <cassert>
+#include <utility>
+
+#include "../types.h"
+#include "test_comparisons.h"
+
+template <class I1, class I2 = I1>
+concept CanEq = requires(const I1& i1, const I2& i2) {
+  { i1 == i2 } -> std::same_as<bool>;
+  { i2 == i1 } -> std::same_as<bool>;
+  { i1 != i2 } -> std::same_as<bool>;
+  { i2 != i1 } -> std::same_as<bool>;
+};
+
+constexpr bool test() {
+  { // `V` and `Pattern` are not empty. Test return types too.
+    using V       = std::array<std::array<int, 2>, 3>;
+    using Pattern = std::array<long, 1>;
+    using JWV     = std::ranges::join_with_view<std::ranges::owning_view<V>, std::ranges::owning_view<Pattern>>;
+
+    using Iter  = std::ranges::iterator_t<JWV>;
+    using CIter = std::ranges::iterator_t<const JWV>;
----------------
huixie90 wrote:

can we `static_assert(!std::same_as<Iter, CIter>))` to make sure we have coverage from cross-const comparison?  ( I don't see it in the spec. I suppose it works because of the implicit conversion constructor)

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


More information about the libcxx-commits mailing list