| 7 | (__cpp_designated_initializers >= 201707L) && not defined(__clang__) |
| 8 | |
| 9 | int main() |
| 10 | { |
| 11 | struct Point { |
| 12 | int y; |
| 13 | int x; |
| 14 | int z; |
| 15 | }; |
| 16 | |
| 17 | struct Nested { |
| 18 | int i; |
| 19 | Point pt; |
| 20 | }; |
| 21 | |
| 22 | struct LifeTimeExtension { |
| 23 | int&& r; // #A Notice the r-value reference |
| 24 | }; |
| 25 | |
| 26 | // #B Initialization of an aggregate |
| 27 | Point bPt{2, 3, 5}; |
| 28 | Point pPt(2, 3, 5); // #C Since C++20 |
| 29 | |
| 30 | // #D Initialization of an array |
| 31 | int bArray[]{2, 3, 5}; |
| 32 | int pArray[](2, 3, 5); // #E Since C++20 |
| 33 | |
| 34 | Nested bNested{ |
| 35 | 9, {3, 4, 5}}; // #F Initialization of nested aggregate with nested braces |
| 36 | // Nested pNested(9,( 3,4,5));// #G Nested parentheses are a different thing |
| 37 | |
| 38 | Point bDesignated{.y = 3}; // #H Designated initializers works |
| 39 | // Point pDesignated(.y=3);// #I Designated initializers are not supported |
| 40 | |
| 41 | // Point bNarrowing{3.5};// #J Does not allow narrowing |
| 42 | Point pNarrowing(3.5); // #K Allows narrowing |
| 43 | |
| 44 | Point bValueInit{}; // #L Default or zero initialization |
| 45 | Point pValueInit(); // #M Still a function declaration |
| 46 | |
| 47 | // #N Initialization of a built-in type |
| 48 | int bBuiltIn{4}; |
| 49 | int pBuiltIn(4); |
| 50 | |
| 51 | LifeTimeExtension bTemporary{4}; // #O Ok |
| 52 | LifeTimeExtension pTemporary(4); // #P Dangling reference |
| 53 | } |
| 54 | #else |
| 55 | int main() |
| 56 | { |
nothing calls this directly
no outgoing calls
no test coverage detected