Is it possible to use tokens as template parameters?

Ali Çehreli acehreli at yahoo.com
Mon Aug 16 17:59:36 UTC 2021


On 8/15/21 1:40 AM, Daniel N wrote:

 > static struct Yay
 > {
 >      string opDispatch(string name, T...)(T vals)

I sometimes wish templates had opDispatch abilities. Then we could 
instantiate a template with a symbol and the the template could receive 
it as string just like the way it works for opDispatch. So, this could work:

   Flag!isCool isCool;

instead of today's

   Flag!"isCool" isCool;

Basically, it would still be a string parameter but the quotes need not 
be provided:

template Flag(string tag) {
   // ...
}

I realize that this might hide some bugs but so does opDispatch, no?

Ali



More information about the Digitalmars-d mailing list