Attributes not propagating to objects via typeinfo?

rsw0x via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Aug 13 06:24:23 PDT 2015


On Thursday, 13 August 2015 at 03:46:19 UTC, rsw0x wrote:
> 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?

bump, is this working as intended?


More information about the Digitalmars-d-learn mailing list