Книга: Standard Template Library Programmer
Function object adaptors
Разделы на этой странице:
Categories: functors, adaptors
Component type: type
Binder1st 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 binder1st<AdaptableBinaryFunction>, then f(x) returns F(c, x), where F is an object of class AdaptableBinaryFunction and where c is a constant. Both F and c are passed as arguments to binder1st 's constructor. 
The easiest way to create a binder1st is not to call the constructor explicitly, but instead to use the helper function bind1st.
Finds the first nonzero element in a list.
list<int>::iterator first_nonzero = find_if(L.begin(), L.end(), bind1st(not_equal_to<int>(), 0));
assert(first_nonzero == L.end() || *first_nonzero != 0);
Defined in the standard header functional, and in the nonstandard backward-compatibility header function.h.
||The type of the binary function whose first argument is being bound to a constant.|
Adaptable Unary Function
AdaptableBinaryFunction must be a model of Adaptable Binary Function.
Public base classes
||Adaptable Unary Function||The type of the function object's argument, which is AdaptableBinaryFunction::second_argument_type|
||Adaptable Unary Function||The type of the result: AdaptableBinaryFunction::result_type|
||Adaptable Unary Function||Function call. Returns F(c, x), where F and c are the arguments with which this binder1st was constructed.|
These members are not defined in the Adaptable Unary Function requirements, but are specific to binder1st.
||The constructor. Creates a binder1st such that calling it with the argument x (where x is of type AdaptableBinaryFunction::second_argument_type ) corresponds to the call F(c, x).|
||If F is an object of type AdaptableBinaryFunction, then bind1st(F, c) is equivalent to binder1st<AdaptableBinaryFunction>(F, c), but is more convenient. The type T must be convertible to AdaptableBinaryFunction::first_argument_type. This is a global function, not a member function.|
 Intuitively, you can think of this operation as "binding" the first argument of a binary function to a constant, thus yielding a unary function. This is a special case of a closure.
The function object overview, binder2nd, Adaptable Unary Function, Adaptable Binary Function
- Function Objects
- Member function adaptors
- EXTERNAL FUNCTION DIRECTORY
- CHAPTER 4 Functions and Libraries in mikroC
- Creating and Deleting Device Objects
- Scaling makes your object darker?
- 5.1.1. The Image Object
- Переопределение System.Object.GetHashCode()
- Object Orientation