Is there Typeof template ?

Ali Çehreli via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 28 11:39:36 PDT 2016


On 10/28/2016 11:25 AM, Jonathan M Davis via Digitalmars-d-learn wrote:

 >> void main() {
 >>      @(`str`, 123) uint k;
 >>      foreach (a; __traits(getAttributes, k)) {
 >>          pragma(msg, typeof(a));
 >>      }
 >> }

 > I don't know if Typeof is actually needed for what the OP is trying 
to do,
 > but if you wanted to apply typeof using something like 
std.meta.staticMap,
 > then you'd need something like Typeof.

I see.

Just to add something that I've just remembered, it is possible to apply 
typeof to __traits(getAttributes) as well:

     foreach (T; typeof(__traits(getAttributes, k))) {
         pragma(msg, T);
     }

Now we get a list of types:

string
int

Ali



More information about the Digitalmars-d-learn mailing list