C macros vs D can't do the right thing

Jacob Carlborg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sat Jun 3 07:19:00 PDT 2017


On 2017-06-03 16:03, Nicholas Wilson wrote:

> I think an alias template parameter will work here as aliases take
> anything(types, literals, symbols).

No, it doesn't work for types:

void foo(alias a)() {}

void main()
{
     foo!(int)();
}

Results in:

Error: template instance foo!int does not match template declaration 
foo(alias a)()

Perhaps using the variadic template with a constraint on one element 
trick will work. Ugly, but I think that will work.

-- 
/Jacob Carlborg


More information about the Digitalmars-d-learn mailing list