On Sunday, 18 February 2018 at 15:12:50 UTC, Mike Parker wrote:

Generally, no. But with alias this, it can be:

=====
import std.traits : BooleanTypeOf;
import std.stdio : writeln;

struct NoBool {
    int x;
}

struct AliasThisBool {
    bool b;
    alias b this;
}

void main()
{
    static if(is(BooleanTypeOf!NoBool)) writeln("NoBool");
static if(is(BooleanTypeOf!AliasThisBool)) writeln("AliasThisBool");
}

Thanks!

It doesn't appear that BooleanTypeof is documented on dlang.org (outside of it's placement on the isBooleanType page). At least it isn't coming up in a "BooleanTypeOf site:dlang.org" search and not on the traits page:

https://dlang.org/library/std/traits.html

Reply via email to