std.reflection prototype
bitwise via Digitalmars-d
digitalmars-d at puremagic.com
Wed Apr 15 16:52:04 PDT 2015
One more thing.
I had to add a virtual destructor to A to get this to work:
class A {
public: int a; virtual ~A(){}
};
// ....
A *d2 = (A*)d;
cout << boolalpha << (typeid(*d2) == typeid(D)) << endl;
C *d3 = (C*)d;
cout << boolalpha << (typeid(*d3) == typeid(D)) << endl;
Output is now:
true
false
Without virtual destructor:
false
false
So you can't rely on serialization working properly using only
TypeInfo/offsets
More information about the Digitalmars-d
mailing list