On Thursday, 23 January 2014 at 23:42:26 UTC, Uplink_Coder wrote:
When I try to

struct _pod_ {
  string s1;
  enum e1 { v1,v2 };
}

auto printPod(Pod)() if (__traits(isPOD,Pod)) {
        string result;
        foreach (member;__traits(allMembers,Pod) ) {
                auto _member=__traits(getMember,Pod,member);
        }
        writeln(result);
}
void main() {printPod!(_pod_);}

I get
Error: need 'this' for 's1' of type 'string'
Error: type e1 has no value

__traits(getMember, Pod, member) is the same as Pod.member. In your case Pod is _pod_, so in the end you are trying to access an non-static member via the struct type. That cannot work and the error message tells you exactly that in errorspeak.

Since you are never appending to result your code has some more flaws and I'm not sure what you are trying to do? Do you try to mirror std.conv.to!string?

Reply via email to