October 11, 2019
I want to check whether

    auto _ = pred(T.init);
    static assert(is(typeof(_) == bool));

compiles or not.

Which one

    __traits(compiles, { auto _ = pred(T.init); static assert(is(typeof(_) == bool)); })

and

    is(typeof(pred(T.init)) == bool)

is preferred compilation performance-wise?
October 11, 2019
On Friday, 11 October 2019 at 09:05:25 UTC, Per Nordlöw wrote:
> I want to check whether
>
>     auto _ = pred(T.init);
>     static assert(is(typeof(_) == bool));
>
> compiles or not.
>
> Which one
>
>     __traits(compiles, { auto _ = pred(T.init); static assert(is(typeof(_) == bool)); })
>
> and
>
>     is(typeof(pred(T.init)) == bool)
>
> is preferred compilation performance-wise?

Seems like the second one requires strictly less semantic analysis and is shorter and easier to read, so I'd go with that.

Note that `pred(T.init)` will fail if pred accepts its argument by ref. If you want to handle that case, you have to do something like

    is(ReturnType!((T arg) => pred(arg)) == bool))