Reference Tuples
dsimcha
dsimcha at yahoo.com
Wed Oct 8 18:49:36 PDT 2008
I'm trying to do some deep metaprogramming magic in D2, and an issue that I
can't seem to get around is that I can't find a way to get a tuple of
struct/class fields, or something similarly useful, with reference semantics. Ex:
struct S {
uint foo = 1;
}
void main() {
S s;
foreach(element; s.tupleof)
element = 2;
writeln(s.foo); //Still 1.
}
The obvious thing, which I already tried was:
foreach(ref element; s.tupleof) //Doesn't compile.
Is there a way to get a tuple representation of a class/struct such that I can
change the fields of the class/struct through the tuple representation, or
should I file this as an enhancement?
More information about the Digitalmars-d
mailing list