| 1 |
/* |
| 2 |
TEST_OUTPUT: |
| 3 |
--- |
| 4 |
fail_compilation/diag13884.d(14): Error: functions cannot return a sequence (use `std.typecons.Tuple`) |
| 5 |
fail_compilation/diag13884.d(21): instantiated from here: `MapResult!((t) => t.tupleof, Foo[])` |
| 6 |
fail_compilation/diag13884.d(14): instantiated from here: `map!(Foo[])` |
| 7 |
--- |
| 8 |
*/ |
| 9 |
|
| 10 |
struct Foo { int x; } |
| 11 |
|
| 12 |
void main() |
| 13 |
{ |
| 14 |
[Foo(1)].map!(t => t.tupleof); |
| 15 |
} |
| 16 |
|
| 17 |
template map(fun...) |
| 18 |
{ |
| 19 |
auto map(Range)(Range r) |
| 20 |
{ |
| 21 |
return MapResult!(fun, Range)(r); |
| 22 |
} |
| 23 |
} |
| 24 |
|
| 25 |
struct MapResult(alias fun, R) |
| 26 |
{ |
| 27 |
R _input; |
| 28 |
|
| 29 |
@property auto ref front() |
| 30 |
{ |
| 31 |
return fun(_input[0]); |
| 32 |
} |
| 33 |
|
| 34 |
} |