回调 两种不同的使用方式
2018-03-20 08:31
218 查看
#include <functional>
#include <iostream>
// one method
using callback = std::function<void()>;
// another method
//typedef std::function<void()> callback;
void f1()
{
std::cout << "a" << std::endl;
}
void call(callback f)
{
f();
}
int main(int argc,char** argv)
{
callback c1 = std::bind(&f1);
call(c1);
return 0;
}
#include <iostream>
// one method
using callback = std::function<void()>;
// another method
//typedef std::function<void()> callback;
void f1()
{
std::cout << "a" << std::endl;
}
void call(callback f)
{
f();
}
int main(int argc,char** argv)
{
callback c1 = std::bind(&f1);
call(c1);
return 0;
}
相关文章推荐
- 使用SQL Server 2005 新的语法ROW_NUMBER()进行分页的两种不同方式的性能比较
- 使用SQL Server 2005 新的语法ROW_NUMBER()进行分页的两种不同方式的性能比较
- 使用PopupWindow和Activity两种不同的方式实现弹窗效果
- 创建字符串对象的时候,使用字面值和使用new String()构造器这两种方式有什么不同?
- 使用PopupWindow和Activity两种不同的方式实现弹窗效果
- Android 使用adapter的两种回调数据方式
- 使用ODBC和OLEDB两种方式执行同一个存储过程,结果不同的问题!
- 使用两种不同的方式复制字符串
- jersey 文件上传-使用两种不同的方式
- 使用SQL Server 2005 新的语法ROW_NUMBER()进行分页的两种不同方式的性能比较
- Qt 多线程两种使用方式不同
- 一个简单的系统配置文件使用DTD和XSD两种方式描述
- 使用两种方式自定义jQuery插件
- Android Studio 2.2 使用 OpenCV 的两种方式(傻瓜式教程)
- Android广播的两种注册使用方式。
- java application应用程序 使用JDBC和proxool两种方式连接数据库 的测试程序代码
- 使用POST方式弹出窗口的两种方法
- CSS float的初步理解:用两种不同的方式来实现一个三列布局,其中左侧和右侧的部分宽度固定,中间部分宽度随浏览器宽度的变化而自适应变化
- Jenkins不同job之间依赖关系的两种配置方式
- JAVA多线程实现方式主要有三种:继承Thread类、实现Runnable接口、使用ExecutorService、Callable、Future实现有返回结果的多线程。其中前两种方式线程执行完后都没