Flatten a range of static arrays
nullptr
null at p.tr
Fri Feb 7 23:10:29 UTC 2020
On Friday, 7 February 2020 at 22:55:29 UTC, Dennis wrote:
> Oops, minimized a bit too much. Corrected test case:
> ```
> import std;
>
> struct S {
> @safe:
> 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;
> }
> ```
> It indeed still errors with -dip1000, but without -dip1000 it
> compiles now interestingly.
```
import std;
struct SomeRange
{
int[3] val;
enum empty = false;
auto popFront() @safe {}
ref auto front() @safe
{
return val;
}
}
void main() @safe
{
SomeRange().take(10).map!((return ref x) =>
x[]).joiner.writeln;
}
```
I don't know how applicable this is to your use case, but this
code will compile and run under -dip1000.
More information about the Digitalmars-d-learn
mailing list