module stringarrayenum;
import std.stdio;
import std.conv;
void main()
{
MyEnum foo = MyEnum.a;
//~ foo = ["a", "b", "c"]; // fails, as it should
MyEnum bar;
bar = MyEnum.a;
assert(foo == bar);
writeln(foo);
}
struct MyEnum
{
typedef string[] StrArr;
StrArr payload;
this(T)(T value) if (is(T == StrArr))
{
this.payload = value;
}
void opAssign(T)(T value) if (is(T == StrArr))
{
this.payload = value;
}
alias payload this;
string toString()
{
return to!string(cast(string[])payload);
}
enum
{
a = cast(StrArr)["a", "b", "c"],
b = cast(StrArr)["d", "e", "f"],
c = cast(StrArr)["g", "h", "i"],
}
}