template <class Operation, class T> binder1st<Operation> bind1st (const Operation& op, const T& x); |
template <class Operation, class T> binder1st<Operation> bind1st (const Operation& op, const T& x) { return binder1st<Operation>(op, typename Operation::first_argument_type(x)); } |
// bind1st example #include <iostream> #include <functional> #include <algorithm> using namespace std; int main () { int numbers[] = {10,20,30,40,50,10}; int cx; cx = count_if (numbers, numbers+6, bind1st(equal_to<int>(),10) ); cout << "There are " << cx << " elements that are equal to 10.\n"; return 0; } |
bind2nd | 返回第二个参数绑定的函数对象(类模板) |
binder1st | 生成绑定一个参数的函数对象类(类模板) |
unary_function | 一元函数对象基类 (类模板) |
binary_function | 二元函数对象基类 (类模板) |