View source code Display the source code in std/functional.d from which this page was generated on github. Improve this page Quickly fork, edit online, and submit a pull request for this page. Requires a signed-in GitHub account. This works well for small changes. If you'd like to make larger changes you may want to consider using local clone. Page wiki View or edit the community-maintained wiki page associated with this page.

Template std.functional.partial

Partially applies fun by tying its first argument to arg.

Arguments

template partial(alias fun, alias arg);

Example

int fun(int a, int b) { return a + b; }
alias partial!(fun, 5) fun5;
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.

Authors

Andrei Alexandrescu

License

Boost License 1.0.

Comments