Class Field Size/Offsets
Maxime Chevalier
maximechevalierb at gmail.com
Sat Mar 2 14:08:47 PST 2013
Your example works but my use case doesn't and I have no idea why:
class C { int a; }
struct Foo
{
void foo(string className, string fieldName)()
{
mixin("auto sz = " ~ className ~ "." ~ fieldName ~
".sizeof;");
writefln("sz: %s", sz);
}
}
static this()
{
Foo f;
f.foo!("C", "a");
}
Produces:
Error: this for a needs to be type C not type Foo
Error: template instance Foo.foo!("C", "a") error instantiating
More information about the Digitalmars-d
mailing list