| 1 |
// PR c++/101165 - P2266R1 - Simpler implicit move |
| 2 |
// { dg-do compile { target c++20 } } |
| 3 |
// Test from P2266R1, $ 3.3. Two overload resolutions are overly confusing. |
| 4 |
|
| 5 |
struct Widget { |
| 6 |
Widget(); |
| 7 |
Widget(Widget&&); |
| 8 |
}; |
| 9 |
|
| 10 |
struct Frodo { |
| 11 |
Frodo(Widget&); |
| 12 |
Frodo(Widget&&) = delete; |
| 13 |
}; |
| 14 |
|
| 15 |
struct Sam { |
| 16 |
Sam(Widget&) = delete; // #1 |
| 17 |
Sam(const Widget&); // #2 |
| 18 |
}; |
| 19 |
|
| 20 |
Sam twelve() { |
| 21 |
Widget w; |
| 22 |
// This is supposed to call #2 since C++20 because P1155. |
| 23 |
// But we actually choose #1 since r11-2411 (in C++20 only). |
| 24 |
return w; // { dg-error "deleted" "" { target c++20_only } } |
| 25 |
} |
| 26 |
|
| 27 |
Frodo thirteen() { |
| 28 |
Widget w; |
| 29 |
// This is a correct error in both C++20 and C++23. |
| 30 |
return w; // { dg-error "use of deleted function" } |
| 31 |
} |
| 32 |
|
| 33 |
struct Merry {}; |
| 34 |
struct Pippin {}; |
| 35 |
struct Together : Merry, Pippin {}; |
| 36 |
struct Quest { |
| 37 |
Quest(Merry&&); |
| 38 |
Quest(Pippin&&); |
| 39 |
Quest(Together&); |
| 40 |
}; |
| 41 |
|
| 42 |
Quest fourteen() { |
| 43 |
Together t; |
| 44 |
// C++20: calls Quest(Together&). Proposed: ill-formed. |
| 45 |
return t; // { dg-error "ambiguous" "" { target c++23 } } |
| 46 |
} |