partial

Partially applies fun by tying its first argument to arg.

template partial(alias fun, alias arg)
partial
(
Ts...
)
()

Parameters

fun

A callable

arg

The first argument to apply to fun

Return Value

A new function which calls fun with arg plus the passed parameters.

Examples

int fun(int a, int b) { return a + b; }
alias fun5 = partial!(fun, 5);
assert(fun5(6) == 11);
// Note that in most cases you'd use an alias instead of a value
// assignment. Using an alias allows you to partially evaluate template
// functions without committing to a particular type of the function.

Meta

Suggestion Box / Bug Report