Skip to content

Commit 1cb7b40

Browse files
committed
expect assign, formatting and fix shadow
1 parent 9ce787b commit 1cb7b40

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

libcxx/test/std/utilities/expected/expected.expected/assign/assign.U.pass.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,41 @@ constexpr bool test() {
325325
}
326326
}
327327

328+
// Check move constructor selection
329+
{
330+
struct MoveOnlyMulti {
331+
bool used_move1 = false;
332+
bool used_move2 = false;
333+
334+
constexpr MoveOnlyMulti() = default;
335+
constexpr MoveOnlyMulti(const MoveOnlyMulti&) = delete;
336+
constexpr MoveOnlyMulti& operator=(const MoveOnlyMulti&) = delete;
337+
constexpr MoveOnlyMulti& operator=(MoveOnlyMulti&&) {
338+
used_move1 = true;
339+
return *this;
340+
}
341+
constexpr MoveOnlyMulti& operator=(const MoveOnlyMulti&&) {
342+
used_move2 = true;
343+
return *this;
344+
};
345+
constexpr MoveOnlyMulti(MoveOnlyMulti&&) : used_move1(true) {}
346+
constexpr MoveOnlyMulti(const MoveOnlyMulti&&) : used_move2(true) {}
347+
};
348+
349+
{
350+
MoveOnlyMulti t{};
351+
std::expected<MoveOnlyMulti, int> e1(std::unexpect);
352+
e1 = std::move(t);
353+
assert(e1.value().used_move1);
354+
}
355+
{
356+
const MoveOnlyMulti t{};
357+
std::expected<MoveOnlyMulti, int> e1(std::unexpect);
358+
e1 = std::move(t);
359+
assert(e1.value().used_move2);
360+
}
361+
}
362+
328363
return true;
329364
}
330365

libcxx/test/std/utilities/expected/expected.expected/ctor/ctor.u.pass.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ struct MoveOnly2 {
8585
bool used_move1 = false;
8686
bool used_move2 = false;
8787

88-
constexpr explicit MoveOnly2(int j) : j(j) {}
88+
constexpr explicit MoveOnly2(int jj) : j(jj) {}
8989
constexpr MoveOnly2(const MoveOnly2&) = delete;
9090
constexpr MoveOnly2(MoveOnly2&& m) : j(m.j), used_move1(true) {}
9191
constexpr MoveOnly2(const MoveOnly2&& m) : j(m.j), used_move2(true) {}

libcxx/test/std/utilities/optional/optional.object/optional.object.ctor/U.pass.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -134,12 +134,12 @@ void test_explicit() {
134134
}
135135
T::reset();
136136
{
137-
optional<T> t{43};
138-
assert(T::alive == 1);
139-
assert(T::value_constructed == 1);
140-
assert(T::move_constructed == 0);
141-
assert(T::copy_constructed == 0);
142-
assert(t.value().value == 43);
137+
optional<T> t{43};
138+
assert(T::alive == 1);
139+
assert(T::value_constructed == 1);
140+
assert(T::move_constructed == 0);
141+
assert(T::copy_constructed == 0);
142+
assert(t.value().value == 43);
143143
}
144144
assert(T::alive == 0);
145145
}

0 commit comments

Comments
 (0)