[libcxx-commits] [libcxx] [libc++] Implement Resolution of LWG 3886 (PR #155356)
A. Jiang via libcxx-commits
libcxx-commits at lists.llvm.org
Tue Sep 2 02:04:43 PDT 2025
================
@@ -325,6 +325,41 @@ constexpr bool test() {
}
}
+ // Check move constructor selection
+ {
+ struct MoveOnlyMulti {
+ bool used_move1 = false;
+ bool used_move2 = false;
+
+ constexpr MoveOnlyMulti() = default;
+ constexpr MoveOnlyMulti(const MoveOnlyMulti&) = delete;
+ constexpr MoveOnlyMulti& operator=(const MoveOnlyMulti&) = delete;
+ constexpr MoveOnlyMulti& operator=(MoveOnlyMulti&&) {
+ used_move1 = true;
+ return *this;
+ }
+ constexpr MoveOnlyMulti& operator=(const MoveOnlyMulti&&) {
+ used_move2 = true;
+ return *this;
+ };
+ constexpr MoveOnlyMulti(MoveOnlyMulti&&) : used_move1(true) {}
+ constexpr MoveOnlyMulti(const MoveOnlyMulti&&) : used_move2(true) {}
+ };
+
+ {
+ MoveOnlyMulti t{};
+ std::expected<MoveOnlyMulti, int> e1(std::unexpect);
+ e1 = std::move(t);
----------------
frederick-vs-ja wrote:
Looks like that we should test with `{}`, ditto below.
```suggestion
e1 = {std::move(t)};
```
https://github.com/llvm/llvm-project/pull/155356
More information about the libcxx-commits
mailing list