Flatten a range of static arrays
Dennis
dkorpel at gmail.com
Fri Feb 7 21:17:25 UTC 2020
On Friday, 7 February 2020 at 20:55:14 UTC, nullptr wrote:
> Depending on how your range is structured, it might be possible
> to just mark front as returning by ref to make this work.
That's a good one. I can't make front() return by ref, but I can
make front a member variable of the range struct. Only problem:
@safe function ... cannot call @system function
std.algorithm.iteration.joiner!(...).joiner
I don't know why. I don't have time to delve into this at the
moment but if anyone wants to try, here's a minimal testcase:
```
import std;
struct S {
int[3] front = [10, 20, 30];
bool empty = false;
void popFront() {empty = true;}
}
void main() @safe {
S.init.map!((return ref x) => x[]).joiner.writeln;
}
```
flags: -dip1000 -dip25
More information about the Digitalmars-d-learn
mailing list