On Saturday, 30 June 2018 at 21:11:54 UTC, Anonymouse wrote:
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'`);
}
I'd send you straight to std.meta.ApplyLeft, but it seems to do
the wrong thing here, in that it doesn't handle IFTI. This thing
does:
void fooImpl(int n, T)(const T line) { }
unittest {
alias fun = applyLeft!(fooImpl, 3);
fun(`aaa`);
applyLeft!(fooImpl, 3)(`aaa`);
}
template applyLeft(alias Fn, T...) {
auto applyLeft(U...)(U args) {
return Fn!T(args);
}
}
--
Simen