ptr_fun
来源:互联网 发布:制表软件 编辑:程序博客网 时间:2024/06/06 10:00
头文件:<functional>
ptr_fun是将一个普通的函数适配成一个仿函数(functor), 添加上argument_type和result type等类型,它的定义如下:
- template<class _Arg1,
- class _Arg2,
- class _Result> inline
- pointer_to_binary_function<_Arg1, _Arg2, _Result,
- _Result(__clrcall *)(_Arg1, _Arg2)>
- ptr_fun(_Result (__clrcall *_Left)(_Arg1, _Arg2))
- { // return pointer_to_binary_function functor adapter
- return (pointer_to_binary_function<_Arg1, _Arg2, _Result,
- _Result (__clrcall *)(_Arg1, _Arg2)>(_Left));
- }
- #include <algorithm>
- #include <functional>
- #include <iostream>
- using namespace std;
- int sum(int arg1, int arg2)
- {
- std::cout<< "arg1 = " << arg1 << std::endl;
- std::cout<< "arg2 = " << arg2 << std::endl;
- int sum = arg1 + arg2;
- std::cout << "sum = " << sum << std::endl;
- return sum;
- }
- int main(int argc, char *argv[], char *env[])
- {
- bind1st(ptr_fun(sum), 1)(2); // the same as sum(1,2)
- bind2nd(ptr_fun(sum), 1)(2); // the same as sum(2,1)
- return 0;
- }
0 0
- ptr_fun
- ptr_fun
- ptr_fun
- ptr_fun详解
- ptr_fun详解
- ptr_fun,mem_fun,mem_fun_ref 浅析
- 【STL】ptr_fun详解
- STL中的ptr_fun
- mem_fun_t/ptr_fun等用法
- ptr_fun学习笔记
- C++标准库---ptr_fun()
- ptr_fun mem_fun_ref mem_fun bind1st bind2nd
- 配接器ptr_fun的一点增补
- mem_fun_ref,mem_fun,not1,not2,ptr_fun
- mem_fun_ref,mem_fun,not1,not2,ptr_fun
- ptr_fun,mem_fun,mem_fun_ref的使用
- 使用ptr_fun、mem_fun和mem_fun_ref
- ptr_fun,mem_fun仿函数类适配器
- 编译过程中遇到的一些错误
- 1153 - Got a packet bigger than 'max_allowed_packet' bytes With statement
- 【LeetCode从零单刷】Longest Consecutive Sequence
- 补充的算法题
- iOS小技巧-UITextFiled/UITextView设置系统圆角边框
- ptr_fun
- opencv学习篇(4)Mat - 基本图像容器
- Xcode 删除过期的Provisioning Profile文件
- CocoaPods使用
- 低功耗蓝牙4.0BLE编程-nrf51822开发(9)
- BZOJ 1082 栅栏 [二分+搜索]
- 玩转Visual Studio-跳出坑爹的Runtime Library库
- 10个迷惑新手的Cocoa&Objective-c开发问题
- 低功耗蓝牙4.0BLE编程-nrf51822开发(10)-描述符