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?

Reply via email to