www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - template alias args

So I keep finding myself in a situation where I need to use an alias
template arg, but what I actually want to alias is a MEMBER of some symbol,
or even a function local.

struct MyStruct
   int x;

template Thing(alias t)

MyStruct s;

Thing!(s); // this is fine
Thing!(s.x); // this doesn't work

This seems like it should work intuitively, I was very surprised when it
didn't. 's.x' can be resolved just as easily as 's' at compile time, but
Walter said 'alias' could only understand absolute symbols, not symbol +
Has anyone else run into this? What's the reason for the restriction?

I've also found I need to do this on a number of occasions: template
Thing(alias T...)
Ie, receive an unknown number of aliases... But that doesn't work either.
May 21 2012