Binder2nd is a function object adaptor: it is used to transform
an adaptable binary function into an adaptable unary function.
Specifically, if f is an object of class
binder2nd<AdaptableBinaryFunction>, then f(x) returns
F(x, c), where F is an object of class AdaptableBinaryFunction
and where c is a constant. Both F and c are passed as arguments to
binder2nd's constructor. [1]
The easiest way to create a binder2nd
is not to call the constructor explicitly, but instead to use the helper
function bind2nd.
These members are not defined in the
Adaptable Unary Function
requirements, but are specific to
binder2nd.
Member
Description
binder2nd(const AdaptableBinaryFunction& F,
AdaptableBinaryFunction::second_argument_type c)
The constructor. Creates a binder2nd such that calling it with
the argument x (where x is of type
AdaptableBinaryFunction::first_argument_type) corresponds to the
call F(x, c).
If F is an object of type AdaptableBinaryFunction,
then bind2nd(F, c) is equivalent to
binder2nd<AdaptableBinaryFunction>(F, c), but is more convenient.
The type T must be convertible to
AdaptableBinaryFunction::second_argument_type.
This is a global function, not a member function.
[1]
Intuitively, you can think of this operation as "binding" the
second argument of a binary function to a constant, thus yielding
a unary function. This is a special case of a closure.