Attributes not propagating to objects via typeinfo?

rsw0x via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed Aug 12 20:46:17 PDT 2015


Sample code:

class C{}
struct S{}

void main(){
     import std.stdio;
     auto c = new shared C();
     auto s = new shared S();
     writeln(typeid(c)); //modulename.C
     writeln(typeid(s)); //shared(modulename.S)*
     writeln(typeid(c).next); //null
     writeln(typeid(s).next); //shared(modulename.S)
     writeln(typeid(typeid(s).next) is typeid(TypeInfo_Shared)); 
//true
     writeln(typeid(typeid(c)) is typeid(TypeInfo_Shared)); //false
}


What's the reason that the shared propagates to the typeinfo for 
the struct, but not for the class declaration?


More information about the Digitalmars-d-learn mailing list