http://d.puremagic.com/issues/show_bug.cgi?id=3939
--- Comment #1 from bearophile_h...@eml.cc 2010-10-24 18:27:12 PDT ---
Currently this seems the most efficient way to have a static class attribute
that contains a __vptr (here converted to a size_t and named classId):
class Foo {
static immutable size_t classId;
static this() {
classId = *(cast(size_t*)(typeid(Foo).init.ptr));
}
}
void main() {
assert(cast(size_t)((new Foo).__vptr) == Foo.classId);
}
With it DMD 2.049 generates a very light static constructor:
_D4test3Foo12_staticCtor1FZvcomdat
movEAX,_D4test3Foo7__ClassZ[0Ch]
movECX,[EAX]
mov_D4test3Foo7classIdyk,ECX
ret
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
--- You are receiving this mail because: ---