c++ std::bind用法小结。
来源:互联网 发布:家庭资产负债表 知乎 编辑:程序博客网 时间:2024/06/05 03:29
有些新东西,虽然不怎么使用这一套,但经常碰到,还是要了解一下。
小小试验,总结与分享:
#include<functional>#include<iostream>using namespace std;class Cat{public: Cat() { //001使用内部绑定; std::bind(&Cat::cry, this)(); } void cry() { cout << "this is a cat" << endl; } void cry2() { cout << "I'm missing fishes" << endl; }};void print1(){ cout <<"print hello" << endl;}void print2(int a){ cout <<"print "<< a << endl;}int selectMax(int a, int b){ return a > b ? a : b;}void square(int num){ cout <<"result:"<< num*num << endl;}int main(){ Cat c1; //002使用外部绑定; std::bind(&Cat::cry2, &c1)(); //003不带参数; std::bind(print1)(); //004带参数; std::bind(print2, std::placeholders::_1)(12); //005多重绑定 auto selectMaxAndSquare = std::bind(square, std::bind(selectMax, std::placeholders::_1, std::placeholders::_2)); selectMaxAndSquare(3, 6); system("pause"); return 0;}
0 0
- c++ std::bind用法小结。
- C++_std::bind std::function 高级用法
- std::bind std::function 用法
- C++-----------------------------------------------------std::bind
- c++ std::bind 基本用法
- std:weak_ptr 用法小结。
- C++11 std::bind的用法(转)
- C++11 std::bind std::function 高级用法
- C++11 中std::function和std::bind的用法
- C++11 中std::function和std::bind的用法
- C++11 std::bind std::function 高级用法
- C++11 std::bind std::function 高级用法
- std::bind绑定器、std::function、extern C的使用
- std::bind
- std::bind
- std::bind
- std::bind
- std::bind
- 关于iframe中datagrid的高度自适应
- design support library八大模块
- iOS开发网络篇—HTTP协议
- Easyui Datagrid自动调整行号大小
- 使用Retrofit2 RxJava 文件上传
- c++ std::bind用法小结。
- in a frame because it set 'X-Frame-Options' to 'DENY'.
- 使用模板快速编写测试用例
- Android快速开发系列 10个常用工具类
- Maven
- html
- Android的消息机制————读书笔记
- Kinect原理深度剖析
- 数据库中char与varchar类型的区别