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; } });
See Implementation