| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail14669.d(11): Error: `auto` can only be used as part of `auto ref` for template function parameters |
| 5 |
fail_compilation/fail14669.d(16): Error: template instance `fail14669.foo1!()` error instantiating |
| 6 |
fail_compilation/fail14669.d(12): Error: `auto` can only be used as part of `auto ref` for template function parameters |
| 7 |
fail_compilation/fail14669.d(17): Error: template `foo2` is not callable using argument types `!()(int)` |
| 8 |
fail_compilation/fail14669.d(12): Candidate is: `foo2()(auto int a)` |
| 9 |
--- |
| 10 |
*/ |
| 11 |
void foo1()(auto int a) {} |
| 12 |
void foo2()(auto int a) {} |
| 13 |
|
| 14 |
void test1() |
| 15 |
{ |
| 16 |
alias f1 = foo1!(); |
| 17 |
foo2(1); |
| 18 |
} |
| 19 |
|
| 20 |
/* |
| 21 |
TEST_OUTPUT: |
| 22 |
--- |
| 23 |
fail_compilation/fail14669.d(29): Error: cannot explicitly instantiate template function with `auto ref` parameter |
| 24 |
fail_compilation/fail14669.d(38): Error: template instance `fail14669.bar1!int` error instantiating |
| 25 |
fail_compilation/fail14669.d(30): Error: cannot explicitly instantiate template function with `auto ref` parameter |
| 26 |
fail_compilation/fail14669.d(40): Error: template instance `fail14669.bar2!int` error instantiating |
| 27 |
--- |
| 28 |
*/ |
| 29 |
void bar1(T)(auto ref T x) {} |
| 30 |
void bar2(T)(auto ref T x) {} |
| 31 |
|
| 32 |
void test2() |
| 33 |
{ |
| 34 |
int n; |
| 35 |
|
| 36 |
bar1(1); |
| 37 |
bar1(n); |
| 38 |
alias b1 = bar1!(int); |
| 39 |
|
| 40 |
alias b2 = bar2!(int); |
| 41 |
bar2(n); |
| 42 |
bar2(1); |
| 43 |
} |