1 #include <iostream>
2 #include <string>
3 #include <boost/bind.hpp>
4 #include <boost/function.hpp>
5 #include <vector>
6 #include <algorithm>
7 #include <functional>
8 #include <stdlib.h>
9 using namespace std;
10 using namespace boost;
11
12
13 void print(std::ostream &os,int i)
14 {
15 os << i << endl;
16 }
17
18
19 void mainF()
20 {
21 //不可以拷贝的对象可以用ref
22 boost::function<void(int)> pt = boost::bind(print,boost::ref(cout), _1);
23
24 vector<int > v;
25 v.push_back(11);
26 v.push_back(12);
27 v.push_back(13);
28 for_each(v.begin(), v.end(), pt);
29
30 std::cin.get();
31 }