| 1 |
/** |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
Call 0 |
| 5 |
(x: true, y: false) |
| 6 |
Call 1 |
| 7 |
Call 2 |
| 8 |
(x: false, y: false) |
| 9 |
Call 3 |
| 10 |
(x: false, y: true) |
| 11 |
Call 4 |
| 12 |
--- |
| 13 |
|
| 14 |
As of writing this test, template function instances store the function arguments from the call site. |
| 15 |
When looking in cache for an existing template instantiation, matching template arguments isn't |
| 16 |
sufficient: `auto ref` parameters being ref or not also create different template instances. |
| 17 |
This test checks that the special logic for it still works with named arguments. |
| 18 |
*/ |
| 19 |
|
| 20 |
void autoref()(auto ref int x, auto ref int y) |
| 21 |
{ |
| 22 |
pragma(msg, "(x: ", __traits(isRef, x), ", y: ", __traits(isRef, y), ")"); |
| 23 |
} |
| 24 |
|
| 25 |
void main() |
| 26 |
{ |
| 27 |
int REF = 0; |
| 28 |
enum NOT = 0; |
| 29 |
pragma(msg, "Call 0"); |
| 30 |
autoref(y: NOT, x: REF); // new instance |
| 31 |
pragma(msg, "Call 1"); |
| 32 |
autoref(x: REF, y: NOT); // existing instance |
| 33 |
pragma(msg, "Call 2"); |
| 34 |
autoref(x: NOT, y: NOT); // new instance |
| 35 |
pragma(msg, "Call 3"); |
| 36 |
autoref(x: NOT, y: REF); // new instance |
| 37 |
pragma(msg, "Call 4"); |
| 38 |
autoref(y: REF, x: NOT); // existing instance |
| 39 |
} |