enum scope
Trass3r
un at known.com
Sat Jan 28 07:49:28 PST 2012
> import std.conv;
> import std.traits;
>
> string exposeEnumMembersImpl(T)()
> {
> string result;
> foreach (member; EnumMembers!UITableViewRowAnimation)
> result ~= "alias " ~ to!string(T.stringof) ~ "." ~
> to!string(member) ~ " " ~ to!string(member) ~ ";\n";
> return result;
> }
>
> template exposeEnumMembers(T)
> {
> enum exposeEnumMembers = exposeEnumMembersImpl!T();
> }
>
> mixin( exposeEnumMembers!UITableViewRowAnimation );
The extra template is senseless.
And no imports are needed.
string bringToCurrentScope(alias EnumType)()
{
string res = "";
foreach (e; __traits(allMembers, EnumType))
{
res ~= "alias " ~ EnumType.stringof ~ "." ~ e ~ " " ~ e ~ ";\n";
}
return res;
}
mixin(bringToCurrentScope!EnumName);
Anyway the whole point of this thread is to get rid of a crappy
mixin(blabla); after each enum I define!
More information about the Digitalmars-d
mailing list