View source code
Display the source code in std/functional.d from which this page was generated on github.
Report a bug
If you spot a problem with this page, click here to create a Bugzilla issue.
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.

Template std.functional.binaryFun

Transforms a string representing an expression into a binary function. The string must either use symbol names a and b as the parameters or provide the symbols via the parm1Name and parm2Name arguments.

template binaryFun(alias fun, string parm1Name = "a", string parm2Name = "b") ;

Contained Functions



fun a string or a callable
parm1Name the name of the first parameter if fun is a string. Defaults to "a".
parm2Name the name of the second parameter if fun is a string. Defaults to "b".


If fun is not a string, binaryFun aliases itself away to fun.


alias less = binaryFun!("a < b");
assert(less(1, 2) && !less(2, 1));
alias greater = binaryFun!("a > b");
assert(!greater("1", "2") && greater("2", "1"));


Andrei Alexandrescu


Boost License 1.0.