Ticket #1396: transform.cpp

File transform.cpp, 1.0 KB (added by anonymous, 15 years ago)
Line 
1#include <boost/fusion/include/as_vector.hpp>
2#include <boost/fusion/include/transform_view.hpp>
3#include <boost/fusion/include/vector.hpp>
4#include <boost/fusion/include/mpl.hpp>
5#include <boost/mpl/vector.hpp>
6
7
8struct identity
9{
10 template<class FunCall>
11 struct result;
12
13 template <class Fun, class T>
14 struct result<Fun(T)>
15 {
16 typedef T type;
17 };
18
19 template <class T>
20 T& operator()(T& val) const
21 {
22 return val;
23 }
24
25 template <class T>
26 T const& operator()(T const& val) const
27 {
28 return val;
29 }
30};
31
32
33int main()
34{
35 {
36 typedef boost::fusion::vector<int, int> from_t;
37 from_t from;
38 boost::fusion::transform_view<from_t, ::identity> v(from, ::identity());
39
40 boost::fusion::as_vector(v);
41 }
42
43 {
44 typedef boost::mpl::vector<int, int> from_t;
45 from_t from;
46 boost::fusion::transform_view<from_t, ::identity> v(from, ::identity());
47
48 boost::fusion::as_vector(v);
49 }
50}
51