首页 > 其他 > 详细

函数对象适配器之ptr_fun的使用示例

时间:2014-05-07 01:50:08      阅读:334      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
 1 //============================================================================
 2 // Name        : CopyInts4.cpp
 3 // Author      : motein
 4 // Version     :
 5 // Copyright   : Your copyright notice
 6 // Description : Hello World in C++, Ansi-style
 7 //============================================================================
 8 
 9 #include <iostream>
10 #include <algorithm>
11 #include <vector>
12 using namespace std;
13 
14 int u_func(int a)
15 {
16     int ret = a;
17     return ret;
18 }
19 
20 int b_func(int a,int b)
21 {
22     return a+b;
23 }
24 
25 void call()
26 {
27     pointer_to_unary_function<int,int> uf(u_func);
28     cout << uf(100) << endl;
29 
30     pointer_to_binary_function<int,int,int> bf(b_func);
31     cout << bf(111,222) << endl;
32 
33     cout << ptr_fun(u_func)(100) << endl;
34     cout << ptr_fun(b_func)(111,222) << endl;
35 
36 }
37 
38 int main()
39 {
40     call();
41     return 0;
42 }
bubuko.com,布布扣

 

函数对象适配器之ptr_fun的使用示例,布布扣,bubuko.com

函数对象适配器之ptr_fun的使用示例

原文:http://www.cnblogs.com/AmitX-moten/p/3712198.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!