std::bind()的使用
来源:互联网 发布:软件出口退税政策 编辑:程序博客网 时间:2024/05/20 14:18
/** * data: 2017.10.18 * bind()的意义在于,将一个函数和它的参数预先绑定在一起,便成一个无参函数 */#include <iostream>#include <functional>//相当于 给std::bind()重新起了个名字叫 CALLBACK()#define CALLBACK(__FuncName__, ...) std::bind(&__FuncName__, ##__VA_ARGS__)void show(int a){ std::cout<< a <<std::endl;}int sum(int a, int b){ return a+b;}int main(){ show(3); auto a = CALLBACK(show, 1); auto b = CALLBACK(sum, 2, 5); a(); std::cout<<"->"<< b() <<std::endl; //直接使用bind auto c = std::bind(sum, 3, 7); std::cout<<"?->"<< c() <<std::endl; return 0;}
阅读全文
0 0
- std::bind的使用
- std::bind()的使用
- std::bind,std::cref的简单使用
- std::function和std::bind的使用?
- std::tr1::bind的使用
- C++11中std::bind的使用
- 使用std::function和std::bind写的观察者模式
- std::bind绑定器、std::function、extern C的使用
- std::function和std::bind的使用(总结)
- std::tr1::function, std::tr1::bind的使用
- std::function 与 std::bind 的基础使用
- C++ 11 std::function std::bind使用
- C++ std::tr1::bind使用
- c++11 std::bind使用
- C++中std::tr1::function和bind 组件的使用
- C++中std::tr1::function和bind 组件的使用
- C++中std::tr1::function和bind 组件的使用
- C++中std::tr1::function和bind 组件的使用
- [教你警告消除]Warning[Pe1072]: a declaration cannot have a label!
- Git push报错,提示没有权限.
- 数据库数据传给页面处理
- 第十四天 流程结构(上)
- 手机WiFi三点定位系统android
- std::bind()的使用
- getZTreeObj为null情况(getCheckedNodes报错)
- Linux系统控制
- centos7 安装mysql5.7
- 删除一张表中的重复行和左外连接右外连接
- playbook语言结构
- OTT TV系统你最关心的几个问题都在这
- 数据单位复查
- 【传智播客郑州校区分享】最详细的微信小程序讲解