switch4

enum switch4 (
string pred
string do1
string do2
string do3
string do4
)

Examples

int func(bool val)
{
    mixin (switch4!("val",
                "return 1;", "return 2;",
                "return 3;", "return 4;"));
}

assert (func(true) == 3);
assert (func(false) == 4);

int func2(bool val)()
{
    mixin (switch4!("val",
                "return 1;", "return 2;",
                "return 3;", "return 4;"));
}

assert (func2!true == 1);
assert (func2!false == 2);

Meta