[libcxx-commits] [PATCH] D156626: [libc++] Make the constraints as intended.
khjj via Phabricator via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 4 07:45:19 PDT 2023
K1ZeKaTo updated this revision to Diff 547212.
K1ZeKaTo added a comment.
Try to fix CI.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D156626/new/
https://reviews.llvm.org/D156626
Files:
libcxx/include/__iterator/iter_move.h
libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.rvalue.verify.cpp
Index: libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.rvalue.verify.cpp
===================================================================
--- /dev/null
+++ libcxx/test/std/iterators/iterator.requirements/iterator.cust/iterator.cust.move/iter_move.rvalue.verify.cpp
@@ -0,0 +1,44 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// Test the constraints in libc++.
+
+// template<class I>
+// unspecified iter_move;
+
+#include <array>
+#include <utility>
+#include <iterator>
+
+template <typename I>
+class wrapper {
+public:
+ wrapper() = default;
+
+ constexpr explicit wrapper(I i) noexcept : base_(std::move(i)) {}
+
+ // This operator is used to check the constraints work.
+ constexpr decltype(auto) operator*() & noexcept { return base_; }
+
+ // This operator is used to check the constraints work.
+ constexpr auto&& operator*() && noexcept = delete;
+
+private:
+ I base_ = I{};
+};
+
+void test_iter_move_rvalue_verify() {
+ std::array<int, 1> t1;
+ auto first = wrapper{std::move(t1)};
+
+ auto helper = [](auto&& first) requires (!requires{std::ranges::iter_move(std::move(first));}) {};
+ auto _ = std::ranges::iter_move(first);
+ helper(first);
+}
Index: libcxx/include/__iterator/iter_move.h
===================================================================
--- libcxx/include/__iterator/iter_move.h
+++ libcxx/include/__iterator/iter_move.h
@@ -49,8 +49,8 @@
concept __move_deref =
!__unqualified_iter_move<_Tp> &&
requires (_Tp&& __t) {
- *__t;
- requires is_lvalue_reference_v<decltype(*__t)>;
+ *std::forward<_Tp>(__t);
+ requires is_lvalue_reference_v<decltype(*std::forward<_Tp>(__t))>;
};
template<class _Tp>
@@ -58,8 +58,8 @@
!__unqualified_iter_move<_Tp> &&
!__move_deref<_Tp> &&
requires (_Tp&& __t) {
- *__t;
- requires (!is_lvalue_reference_v<decltype(*__t)>);
+ *std::forward<_Tp>(__t);
+ requires (!is_lvalue_reference_v<decltype(*std::forward<_Tp>(__t))>);
};
// [iterator.cust.move]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156626.547212.patch
Type: text/x-patch
Size: 2406 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20230804/8bc907aa/attachment.bin>
More information about the libcxx-commits
mailing list