Re: How do you peek a variant containing a complex value?

2020-02-22 Thread nullptr via Digitalmars-d-learn
On Saturday, 22 February 2020 at 18:00:16 UTC, Vinay Sajip wrote: The following program won't compile if I uncomment the if statement: void main() { Variant v = complex(1.0, 1.0); //if (v.peek!(Complex)) { //writeln("Complex"); //} writeln(v); } I get the same error wi

Re: Flatten a range of static arrays

2020-02-07 Thread nullptr via Digitalmars-d-learn
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)

Re: Flatten a range of static arrays

2020-02-07 Thread nullptr via Digitalmars-d-learn
On Friday, 7 February 2020 at 20:13:57 UTC, Dennis wrote: If I have an input range with element type `int[3]`, how do I easily turn it into a range of `int` so I can map it? If it were an int[3][] I could simply cast it to an int[] before mapping, but I don't want to eagerly turn it into an arr