| 1 |
// REQUIRED_ARGS: |
| 2 |
|
| 3 |
template indexOfReturn(T...) |
| 4 |
{ |
| 5 |
static if (T.length == 0) |
| 6 |
{ |
| 7 |
enum indexOfReturn = -1; |
| 8 |
} |
| 9 |
else static if (T[$ - 1] == "return") |
| 10 |
{ |
| 11 |
enum indexOfReturn = T.length - 1; |
| 12 |
} |
| 13 |
else |
| 14 |
{ |
| 15 |
enum indexOfReturn = indexOfReturn!(T[0..$-1]); |
| 16 |
} |
| 17 |
} |
| 18 |
|
| 19 |
struct Test |
| 20 |
{ |
| 21 |
int n; |
| 22 |
|
| 23 |
ref int getN() return |
| 24 |
{ |
| 25 |
return n; |
| 26 |
} |
| 27 |
|
| 28 |
int getNNonReturn() |
| 29 |
{ |
| 30 |
return n; |
| 31 |
} |
| 32 |
} |
| 33 |
|
| 34 |
void main() |
| 35 |
{ |
| 36 |
assert(indexOfReturn!(__traits(getFunctionAttributes, Test.getN)) != -1); |
| 37 |
assert(indexOfReturn!(__traits(getFunctionAttributes, Test.getNNonReturn)) == -1); |
| 38 |
} |