template alias that includes a parameter

Anonymouse asdf at asdf.net
Sat Jun 30 21:11:54 UTC 2018


I have a template that I want to provide easy aliases for, where 
the aliases includes (partially applies?) a template parameter.


void fooImpl(char token, T)(const T line)
{
     // ...
}

alias quoteFoo(T) = fooImpl!('"', T);
alias singlequoteFoo(T) = fooImpl!('\'', T);

void main()
{
     quoteFoo(`"asdf"`);
     singlequoteFoo(`'asdf'`);
}


...was how I'd imagined it would look.

>onlineapp.d(11): Error: template onlineapp.quoteFoo cannot 
>deduce function from argument types !()(string), candidates are:
>onlineapp.d(6):        onlineapp.quoteFoo(T)

If I manually pass string as a template parameter, like 
quoteFoo!string("bar") or singlequoteFoo!string("baz"), it works.

Can I do it this way or do I need to write wrapping functions?


More information about the Digitalmars-d-learn mailing list