std::bind1st std::bind2nd boost::bind
来源:互联网 发布:商城源码怎么去后门 编辑:程序博客网 时间:2024/06/05 07:15
#include <iostream>#include <string>#include <functional>#include <vector>#include <boost/typeof/typeof.hpp>#include <boost/assign.hpp>#include <boost/bind.hpp>using namespace boost::assign;void print(int v){std::cout << v <<" ";}void print2(int v,int y){std::cout << v + y <<" ";}// binary_function 的三个参数为 第一个参数类型,第二个参数类型,函数的返回值类型struct test2:public std::binary_function<int, std::string,void> {void operator()(int x,std::string y)const{std::cout << x << y << " ";}};struct test1:public std::binary_function<std::string,int, void> {void operator()(std::string y,int x)const{std::cout << x << y << " ";}};int main(){std::vector<int> v;boost::assign::push_back(v),2,1,3,7,5,6;std::for_each(v.begin(),v.end(),print);std::cout << std::endl;std::for_each(v.begin(),v.end(),std::bind1st(test1(),"test"));std::cout << std::endl;std::for_each(v.begin(),v.end(),std::bind2nd(test2(),"test"));std::cout << std::endl;std::cout << std::count_if(v.begin(),v.end(),std::bind1st(std::greater<int>(),10)) << std::endl;std::for_each(v.begin(),v.end(),boost::bind(print2,10,_1));std::cout << std::endl;std::for_each(v.begin(),v.end(),boost::bind(print2,_1,11));std::cout << std::endl;return 0;}
0 0
- std::bind1st std::bind2nd boost::bind
- std::mem_fun vs std::mem_fn, std::bind1st/std::bind2nd vs std::bind
- std::bind1st与std::bind2nd的区别
- std::function std::bind
- std::function std::bind
- C++11的bind,bind1st,bind2nd,function
- std::bind
- std::bind
- std::bind
- std::bind
- std::bind
- std::bind
- std::bind
- 使用boost::bind/std::bind进行封…
- boost::bind,boost::mem_fn,std::mem_fun/mem_fun_ref 比较
- bind1st & bind2nd
- std::function 和 std::bind
- lambda, std::function, std::bind
- 说说推送
- 使用Myeclipse搭建S2SH框架
- 分析Redis架构设计
- HSSF,XSSF和SXSSF的区别
- Jetty 的工作原理以及与 Tomcat 的比较
- std::bind1st std::bind2nd boost::bind
- 【opencv】 配置及C++包含头文件
- Android SDK自带draw9patch工具详细教程
- 32位和64位系统区别及int字节数
- Python脚本批量删除特定后缀名的文件
- JS网页高度设置
- python偏函数partial
- QueryServiceConfig2
- Python模块之pexpect