switch2

enum switch2 (
string pred
string action1
string action2
)

Examples

    static assert (switch2!("val", "return 1;", "return 2;") ==
    q{
    static if (__traits(compiles, { enum b = val; } ))
    {
        static if (val)
            return 1;
        else
            return 2;
    }
    else
    {
        if (val)
            return 1;
        else
            return 2;
    }
});

Meta