| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/fail12744.d(38): Error: incompatible parameter storage classes `ref` and `out` |
| 5 |
fail_compilation/fail12744.d(52): Error: template instance `fail12744.bar12744R!(foo12744O)` error instantiating |
| 6 |
fail_compilation/fail12744.d(38): Error: incompatible parameter storage classes `ref` and `lazy` |
| 7 |
fail_compilation/fail12744.d(53): Error: template instance `fail12744.bar12744R!(foo12744L)` error instantiating |
| 8 |
fail_compilation/fail12744.d(39): Error: incompatible parameter storage classes `out` and `ref` |
| 9 |
fail_compilation/fail12744.d(56): Error: template instance `fail12744.bar12744O!(foo12744R)` error instantiating |
| 10 |
fail_compilation/fail12744.d(39): Error: incompatible parameter storage classes `out` and `lazy` |
| 11 |
fail_compilation/fail12744.d(58): Error: template instance `fail12744.bar12744O!(foo12744L)` error instantiating |
| 12 |
fail_compilation/fail12744.d(40): Error: incompatible parameter storage classes `lazy` and `ref` |
| 13 |
fail_compilation/fail12744.d(61): Error: template instance `fail12744.bar12744L!(foo12744R)` error instantiating |
| 14 |
fail_compilation/fail12744.d(40): Error: incompatible parameter storage classes `lazy` and `out` |
| 15 |
fail_compilation/fail12744.d(62): Error: template instance `fail12744.bar12744L!(foo12744O)` error instantiating |
| 16 |
fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `out` |
| 17 |
fail_compilation/fail12744.d(67): Error: template `bar12744A` is not callable using argument types `!(foo12744O)(int)` |
| 18 |
fail_compilation/fail12744.d(41): Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)` |
| 19 |
fail_compilation/fail12744.d(41): Error: incompatible parameter storage classes `auto ref` and `lazy` |
| 20 |
fail_compilation/fail12744.d(68): Error: template `bar12744A` is not callable using argument types `!(foo12744L)(int)` |
| 21 |
fail_compilation/fail12744.d(41): Candidate is: `bar12744A(alias f)(auto ref PTT12744!f args)` |
| 22 |
--- |
| 23 |
*/ |
| 24 |
template PTT12744(func...) |
| 25 |
{ |
| 26 |
static if (is(typeof(func[0]) P == function)) |
| 27 |
alias PTT12744 = P; |
| 28 |
else |
| 29 |
static assert(0); |
| 30 |
} |
| 31 |
|
| 32 |
void foo12744N( int x) {} |
| 33 |
void foo12744R( ref int x) {} |
| 34 |
void foo12744O( out int x) {} |
| 35 |
void foo12744L(lazy int x) {} |
| 36 |
|
| 37 |
void bar12744N(alias f)( PTT12744!f args) {} |
| 38 |
void bar12744R(alias f)( ref PTT12744!f args) {} |
| 39 |
void bar12744O(alias f)( out PTT12744!f args) {} |
| 40 |
void bar12744L(alias f)( lazy PTT12744!f args) {} |
| 41 |
void bar12744A(alias f)(auto ref PTT12744!f args) {} |
| 42 |
|
| 43 |
void main() |
| 44 |
{ |
| 45 |
alias bNN = bar12744N!foo12744N; |
| 46 |
alias bNR = bar12744N!foo12744R; |
| 47 |
alias bNO = bar12744N!foo12744O; |
| 48 |
alias bNL = bar12744N!foo12744L; |
| 49 |
|
| 50 |
alias bRN = bar12744R!foo12744N; |
| 51 |
alias bRR = bar12744R!foo12744R; |
| 52 |
alias bRO = bar12744R!foo12744O; // error |
| 53 |
alias bRL = bar12744R!foo12744L; // error |
| 54 |
|
| 55 |
alias bON = bar12744O!foo12744N; |
| 56 |
alias bOR = bar12744O!foo12744R; // error |
| 57 |
alias bOO = bar12744O!foo12744O; |
| 58 |
alias bOL = bar12744O!foo12744L; // error |
| 59 |
|
| 60 |
alias bLN = bar12744L!foo12744N; |
| 61 |
alias bLR = bar12744L!foo12744R; // error |
| 62 |
alias bLO = bar12744L!foo12744O; // error |
| 63 |
alias bLL = bar12744L!foo12744L; |
| 64 |
|
| 65 |
bar12744A!foo12744N(1); |
| 66 |
bar12744A!foo12744R(1); |
| 67 |
bar12744A!foo12744O(1); // error |
| 68 |
bar12744A!foo12744L(1); // error |
| 69 |
} |