...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Binding is the act of tying together a function to some
arguments for deferred (lazy) evaluation. Named lazy
functions require a bit of typing. Unlike (unnamed) lambda expressions,
we need to write a functor somewhere offline, detached from the call site.
If you wish to transform a plain function, member function or member variable
to a lambda expression, bind
is your friend.
Note | |
---|---|
Take note that binding functions, member functions or member variables is monomorphic. Rather than binding functions, the preferred way is to write true generic and polymorphic lazy functions. |
There is a set of overloaded bind
template functions. Each bind(x)
function generates a suitable binder object.