OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
variadic_to_vmpl.hpp
1 /*
2  * to_variadic.hpp
3  *
4  * Set of classes to convert from a boost::mpl::vector into an S variadic template
5  * class appling a metafunction F on each element
6  *
7  * boost::mpl::vector<T,A,B> is converted into
8  *
9  * S<F<T>,F<A>,F<B>>
10  *
11  * \see to_variadic
12  *
13  * Created on: Aug 27, 2014
14  * Author: Pietro Incardona
15  */
16 
17 #ifndef V_TRANSFORM_HPP
18 #define V_TRANSFORM_HPP
19 
20 #include <boost/fusion/container/vector.hpp>
21 #include <boost/mpl/int.hpp>
22 #include <boost/mpl/reverse.hpp>
23 #include <boost/mpl/vector.hpp>
24 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
25 #include <boost/fusion/include/at_c.hpp>
26 
28 
38 template<typename F,typename L>
39 struct exit_impl : boost::mpl::equal_to<typename boost::mpl::distance<F,L>::type,boost::mpl::int_<0>>
40 {};
41 
49 template<template<typename> class H, typename F,typename L, bool exit,typename ...Args>
51 {
52  typedef typename boost::mpl::deref<F>::type front_;
53  typedef typename boost::mpl::next<F>::type next_;
54  typedef typename exit_impl<next_,L>::type exit_;
55  typedef typename v_transform_impl<H,next_,L,exit_::value,typename H<front_>::type,Args...>::type type;
56 };
57 
58 
60 template<template<typename> class H,typename F,typename L,typename ...Args>
61 struct v_transform_impl<H,F,L,true,Args...>
62 {
63  typedef boost::fusion::vector<Args...> type;
64 };
65 
66 template<typename Seq>
67 struct seq_traits_impl
68 {
69  typedef typename boost::mpl::begin<Seq>::type first_;
70  typedef typename boost::mpl::end<Seq>::type last_;
71  typedef typename exit_impl<first_,last_>::type exit_;
72 };
73 
90 template<template<typename> class H,typename L>
92 {
94  typedef typename boost::mpl::reverse<L>::type reversed_;
95 
97  typedef typename seq_traits_impl<reversed_>::first_ first;
98 
100  typedef typename seq_traits_impl<reversed_>::last_ last;
101 
104 
106  typedef typename v_transform_impl<H,first,last,exit_::value >::type type;
107 };
108 
109 
111 
112 
121 template<template<typename,typename> class H, typename arg0, typename F,typename L, bool exit,typename ...Args>
123 {
124  typedef typename boost::mpl::deref<F>::type front_;
125  typedef typename boost::mpl::next<F>::type next_;
126  typedef typename exit_impl<next_,L>::type exit_;
128 };
129 
130 
132 template<template<typename,typename> class H,typename arg0, typename F,typename L,typename ...Args>
133 struct v_transform_two_impl<H,arg0,F,L,true,Args...>
134 {
135  typedef boost::fusion::vector<Args...> type;
136 };
137 
154 template<template<typename,typename> class H,typename arg0, typename L>
156 {
158  typedef typename boost::mpl::reverse<L>::type reversed_;
159 
161  typedef typename seq_traits_impl<reversed_>::first_ first;
162 
164  typedef typename seq_traits_impl<reversed_>::last_ last;
165 
168 
170  typedef typename v_transform_two_impl<H,arg0,first,last,exit_::value >::type type;
171 };
172 
174 
175 
176 template <int a, int... id>
178 {
180  typedef typename boost::mpl::push_front<typename to_boost_vmpl_impl<id...>::type,boost::mpl::int_<a>>::type type;
181 };
182 
184 template <int a>
186 {
187  typedef boost::mpl::vector<boost::mpl::int_<a>> type;
188 };
189 
202 template <int... id>
204 {
205  typedef typename to_boost_vmpl_impl<id...>::type type;
206 };
207 
209 template <>
211 {
212  typedef typename boost::mpl::vector<>::type type;
213 };
214 
215 #endif
seq_traits_impl< reversed_ >::last_ last
last element
Recursive specialization of v_transform in case of metafunction with 2 argument.
exit_impl< first, last >::type exit_
calculate the exit condition
Recursive specialization of v_transform.
seq_traits_impl< reversed_ >::first_ first
first element
boost::mpl::push_front< typename to_boost_vmpl_impl< id...>::type, boost::mpl::int_< a > >::type type
push in front the next number
v_transform_impl< H, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
v_transform_two_impl< H, arg0, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
boost::mpl::reverse< L >::type reversed_
reverse the sequence
boost::mpl::reverse< L >::type reversed_
reverse the sequence
Exit condition.
seq_traits_impl< reversed_ >::last_ last
last element
exit_impl< first, last >::type exit_
calculate the exit condition
seq_traits_impl< reversed_ >::first_ first
first element
[v_transform metafunction]