Is there Typeof template ?

Temtaime via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 28 15:40:32 PDT 2016


On Friday, 28 October 2016 at 18:39:36 UTC, Ali Çehreli wrote:
> 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

I wanna use it with staticMap.


More information about the Digitalmars-d-learn mailing list