Finding source of typeid use

Nicholas Wilson via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jul 7 01:49:58 PDT 2017


My library is generating a typeid from somewhere.
e.g.
typeid(const(Pointer!(cast(AddrSpace)1u, float)))

but I have never declared a const of that type nor have I used 
typeid explicitly in my program. Where is this coming from?

The program is just:

enum AddrSpace {
     Global,
     Shared
}
struct Pointer(AddrSpace n,T)
{
     T* ptr;
}
private import std.traits;
struct AutoIndexed(T) if (isInstanceOf(T,Pointer))
{
     T p = void;
     enum  n = TemplateArgsOf!(T)[0];
     alias U = TemplateArgsOf!(T)[1];
     static assert(n == AddrSpace.Global || n == AddrSpace.Shared);

     @property U index()
     {
         static if (n == AddrSpace.Global)
             return p[0]; //Some calculation
         else static if (n == AddrSpace.Shared)
             return p[0];// ditto

     }

     @property void index(U t)
     {
         static if (n == AddrSpace.Global)
             p[0] = t; // ditto
         else static if (n == AddrSpace.Shared)
             p[0] = t; // ditto
     }
     @disable this();
     alias index this;
}

alias aagf = AutoIndexed!(GlobalPointer!(float));

@kernel void auto_index_test(aagf a,
                              aagf b,
                              aagf c)
{
     a = b + c;
}


More information about the Digitalmars-d-learn mailing list