函数对象适配器
仿函数适配器 bind1st、bind2nd 将二元仿函数转为一元仿函数 仿函数适配器 not1、not2 仿函数适配器 ptr_fun 将普通函数转为函数对象,然后就可以与其它仿函数适配器一起使用了 仿函数适配器 mem_fun、mem_fun_ref 将成员函数转为适配器 class MyPrint : public binary_function<int, int, void>{ public: void operator()(int v, int val) const{ cout << "v: " << v << ", val: " << val << ", v + val: " << v + val << endl; } }; void myPrint(int v, int val){ cout << v + val << " "; } class MySort: public binary_function<int, int, bool>{ public: bool operator() (int lhs, int rhs)const{ return lhs > rhs; } }; class MyGreater: public unary_function<int, bool>{ public: bool operator()(int v)const{ return v > 50; } }; void printVec(const vector<int> &v){ for(const auto &p : v){ cout << p << " "; } cout << endl; } class Person{ public: Person(int id, int age):id(id), age(age){} void show(){ cout << "id: " << id << ", age: " << age << endl; } int id; int age; }; int main(){ vector<int> v; for(int i = 0; i < 10; ++i){ v....