On Friday, 27 May 2016 at 14:48:59 UTC, Adam D. Ruppe wrote:
On Friday, 27 May 2016 at 14:43:47 UTC, ArturG wrote:
    if(value is typeof(value).init) ...

that still requiers a special case for floating points, arrays and optionally empty string literals.

Have you tried? That should work in all cases.

does this count?

struct Foo
{
    int x;
    float f;
}

void main()
{
    Foo foo;
    if(foo is typeof(foo).init) "A: does'nt work".writeln;
    foo = Foo();
    if(foo is typeof(foo).init) "B: works".writeln;
}


if you remove the float from the struct both cases work or if you define the float inside the struct like this:

struct Foo
{
    int x;
    // float f = float.init; // does'nt work
    float f = float.nan;
}

Reply via email to