| 1 |
// PR c++/69531 - DR 1307, Overload resolution based on size of array init-list. |
| 2 |
// { dg-do run { target c++20 } } |
| 3 |
// Example from [over.ics.rank]. |
| 4 |
|
| 5 |
int f(int (&&)[] ) { return 1; } // #1 |
| 6 |
int f(double (&&)[] ) { return 2; } // #2 |
| 7 |
int f(int (&&)[2]) { return 3; } // #3 |
| 8 |
|
| 9 |
int |
| 10 |
main () |
| 11 |
{ |
| 12 |
// Calls #1: Better than #2 due to conversion, better than #3 due to bounds. |
| 13 |
if (f({1}) != 1) |
| 14 |
__builtin_abort (); |
| 15 |
// Calls #2: Identity conversion is better than floating-integral conversion. |
| 16 |
if (f({1.0}) != 2) |
| 17 |
__builtin_abort (); |
| 18 |
// Calls #2: Identity conversion is better than floating-integral conversion. |
| 19 |
if (f({1.0, 2.0}) != 2) |
| 20 |
__builtin_abort (); |
| 21 |
// Calls #3: Converting to array of known bound is better than to unknown |
| 22 |
// bound, and an identity conversion is better than floating-integral |
| 23 |
// conversion. |
| 24 |
if (f({1, 2}) != 3) |
| 25 |
__builtin_abort (); |
| 26 |
} |