CTFE Overhaul (Was: RFC: Thrift project proposal (draft))

Andrej Mitrovic andrej.mitrovich at gmail.com
Thu Mar 31 17:56:25 PDT 2011


Ok this is the thing that really gets me with CTFE:

void printFields(T)(T t)
{
    enum fields = [__traits(allMembers, T)];

    foreach (string field; fields)
    {
        mixin("writeln(t." ~ to!string(field) ~ ");");      // fail
        mixin("writeln(t." ~ to!string(fields[0]) ~ ");");  // ok
    }
}

Even though the foreach loop will work, `field` can't be accessed.

Once we have that working, its heaven.


More information about the Digitalmars-d mailing list