测试functional的bind以及相关功能
2014-05-06 17:55
253 查看
注:在VS2010 UPDATE1下测试通过
/*测试functional的bind以及相关功能*/ #include <iostream> #include <functional> using namespace std; using namespace std::placeholders; int TestAdd(int a, int b) { return a+b; } bool TestCompare(int a, int b) { return a<b; } class TestBindClass { public: bool operator() (const int &a, const int &b) const { cout << a << "<" << b << " ? " << ( a<b ? "true" : "false" ) << endl; return a<b; } typedef int first_argument_type; typedef int second_argument_type; typedef bool result_type; }; template <class T> struct greater1 { bool operator() (const T& x, const T& y) const { cout << x << ">" << y << " ? " << ( x>y ? "true" : "false" ) << endl; return x>y; } //void operator() (const T& a, const T& b) const {cout << "a<b ? " << ( a<b ? "true" : "false" ) << endl;} typedef T first_argument_type; typedef T second_argument_type; typedef bool result_type; }; void main() { //test bind function auto fcn1 = bind(TestAdd, 5, 10); cout << fcn1() << endl; //test bind function auto fcn2 = bind(TestCompare, _1, 5); cout << fcn2(4) << endl; //test binder1st function binder1st<greater1<int>> fcn4(greater1<int>(), 6); cout << fcn4(7) << endl; //test binder1st function binder1st<TestBindClass> fcn3(TestBindClass(), 5); cout << fcn3(3) << endl; }
相关文章推荐
- IMX6Q学习笔记——编写LED驱动和测试程序以及相关管脚配置
- vsftpd使用虚拟账号功能以及设置相关权限
- iOS10系统下调用系统功能权限以及相关设置
- Hello World,第 5 部分:Rational Functional Tester:创建健壮和可重用的自动功能测试
- bind命令_Linux bind 命令用法详解:显示或设置键盘按键与其相关的功能
- 功能测试的阶段(不相关资料网址)
- 内存分配以及指针处理的相关测试代码
- Unity3d ZWrite ZTest Blend 相关的测试 以及 Queue
- bind的编译安装以及压力测试工具queryperf的使用
- CRH5.1适配Power9以及Hadoop功能测试
- C++11下的线程池以及灵活的functional + bind + lamda
- 利用jquery实现动态表格的相关操作以及列表全选功能
- 主生产计划的功能以及其相关MRP类型参数
- Android以及ios相关的测试 心得
- VS2012 Unit Test —— 我对IdleTest库动的大手术以及对Xml相关操作进行测试的方式
- 神经网络1.训练和测试(train&test)以及相关关系解释--神经网络开篇
- C++11下的线程池以及灵活的functional + bind + lamda
- 一个Window/Linux(Fedora测试平台)的CPU,磁盘,内存,PC,进程相关信息采集功能
- 制定性能测试策略时,如何设计相应的系统用户数、同时在线并发用户数以及每个具体功能的并发用户数
- 使用openssl实现ECDSA签名以及验证功能(附完整测试源码)