OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
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/mpl/range_c.hpp>
25 #include <boost/fusion/sequence/intrinsic/at_c.hpp>
26 #include <boost/fusion/include/at_c.hpp>
27 #include <boost/mpl/accumulate.hpp>
28 
30 
40 template<typename F,typename L>
41 struct exit_impl : boost::mpl::equal_to<typename boost::mpl::distance<F,L>::type,boost::mpl::int_<0>>
42 {};
43 
51 template<template<typename> class H, typename F,typename L, bool exit,typename ...Args>
53 {
55  typedef typename boost::mpl::deref<F>::type front_;
56 
58  typedef typename boost::mpl::next<F>::type next_;
59 
61  typedef typename exit_impl<next_,L>::type exit_;
62 
65 };
66 
67 
69 template<template<typename> class H,typename F,typename L,typename ...Args>
70 struct v_transform_impl<H,F,L,true,Args...>
71 {
73  typedef boost::fusion::vector<Args...> type;
74 };
75 
77 template<typename Seq>
79 {
81  typedef typename boost::mpl::begin<Seq>::type first_;
82 
84  typedef typename boost::mpl::end<Seq>::type last_;
85 
88 };
89 
106 template<template<typename> class H,typename L>
108 {
110  typedef typename boost::mpl::reverse<L>::type reversed_;
111 
114 
117 
120 
123 };
124 
125 
127 
128 
137 template<template<typename,typename> class H, typename arg0, typename F,typename L, bool exit,typename ...Args>
139 {
141  typedef typename boost::mpl::deref<F>::type front_;
142 
144  typedef typename boost::mpl::next<F>::type next_;
145 
147  typedef typename exit_impl<next_,L>::type exit_;
148 
151 };
152 
154 template<template<typename,typename> class H,typename arg0, typename F,typename L,typename ...Args>
155 struct v_transform_two_impl<H,arg0,F,L,true,Args...>
156 {
158  typedef boost::fusion::vector<Args...> type;
159 };
160 
177 template<template<typename,typename> class H,typename arg0, typename L>
179 {
181  typedef typename boost::mpl::reverse<L>::type reversed_;
182 
185 
188 
191 
194 };
195 
197 
199 
200 
209 template<template<typename,typename> class H, typename arg0, typename F,typename L, bool exit,typename ...Args>
211 {
213  typedef typename boost::mpl::deref<F>::type front_;
214 
216  typedef typename boost::mpl::next<F>::type next_;
217 
219  typedef typename exit_impl<next_,L>::type exit_;
220 
223 };
224 
226 template<template<typename,typename> class H,typename arg0, typename F,typename L,typename ...Args>
227 struct v_transform_two_v2_impl<H,arg0,F,L,true,Args...>
228 {
230  typedef boost::fusion::vector<Args...> type;
231 };
232 
249 template<template<typename,typename> class H,typename arg0, typename L>
251 {
253  typedef typename boost::mpl::reverse<L>::type reversed_;
254 
257 
260 
263 
266 };
267 
269 
281 template <int... id>
283 {
285  typedef boost::mpl::vector<boost::mpl::int_<id>...> type;
286 };
287 
289 
290 template <unsigned T1, unsigned int ...T>
292 {
293  typedef boost::mpl::int_<T1> type;
294 };
295 
296 template <unsigned int T1, unsigned int ...T>
298 {
299  typedef typename last_variadic<T...>::type type;
300 };
301 
302 template <unsigned int T1>
303 struct last_variadic<T1>
304 {
305  typedef boost::mpl::int_<T1> type;
306 };
307 
308 template <unsigned int ... prp>
310 {
311  typedef boost::mpl::range_c<int,first_variadic<prp...>::type::value,last_variadic<prp...>::type::value + 1> rangec;
312 
313  typedef typename boost::mpl::size<rangec>::type size_range;
314 
315  typedef typename boost::mpl::accumulate<rangec,
316  boost::mpl::int_<0>,
317  boost::mpl::plus<typename boost::mpl::placeholders::_2,
318  typename boost::mpl::placeholders::_1>
319  >::type accum;
320 
321  typedef typename to_boost_vmpl<prp...>::type prop_vector;
322 
323  typedef typename boost::mpl::accumulate<prop_vector,
324  boost::mpl::int_<0>,
325  boost::mpl::plus<typename boost::mpl::placeholders::_2,
326  typename boost::mpl::placeholders::_1>
327  >::type accum_prp;
328 
329  typedef boost::mpl::bool_<sizeof...(prp) == size_range::value && accum_prp::value == accum::value > type;
330 };
331 
332 #endif
seq_traits_impl< reversed_ >::last_ last
last element
boost::fusion::vector< Args... > type
Required type.
seq_traits_impl< reversed_ >::last_ last
last element
boost::mpl::next< F >::type next_
next element of the vector
Recursive specialization of v_transform in case of metafunction with 2 argument.
boost::mpl::vector< boost::mpl::int_< id >... > type
construct an mpl vector from the variadic
exit_impl< first, last >::type exit_
calculate the exit condition
Recursive specialization of v_transform.
seq_traits_impl< reversed_ >::first_ first
first element
v_transform_two_v2_impl< H, arg0, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
exit_impl< first, last >::type exit_
calculate the exit condition
boost::fusion::vector< Args... > type
Required type.
v_transform_impl< H, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
boost::fusion::vector< Args... > type
required transformed type
boost::mpl::deref< F >::type front_
last element of the vector
seq_traits_impl< reversed_ >::first_ first
first element
Recursive specialization of v_transform in case of metafunction with 2 argument.
exit_impl< first_, last_ >::type exit_
exit condition (first == last)
v_transform_impl< H, next_, L, exit_::value, typename H< front_ >::type, Args... >::type type
recursive call
v_transform_two_v2_impl< H, arg0, next_, L, exit_::value, typename H< arg0, front_ >::type::type, Args... >::type type
Recursive call.
boost::mpl::end< Seq >::type last_
Last element.
boost::mpl::deref< F >::type front_
last element of the vector
implementation of seq_traits
v_transform_two_impl< H, arg0, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
boost::mpl::next< F >::type next_
next element
KeyT const ValueT ValueT OffsetIteratorT OffsetIteratorT int
[in] The number of segments that comprise the sorting data
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
boost::mpl::next< F >::type next_
next element of the vector
exit_impl< first, last >::type exit_
calculate the exit condition
seq_traits_impl< reversed_ >::first_ first
first element
boost::mpl::begin< Seq >::type first_
first element
exit_impl< next_, L >::type exit_
exit condition
boost::mpl::reverse< L >::type reversed_
reverse the sequence
exit_impl< next_, L >::type exit_
exit condition
boost::mpl::deref< F >::type front_
last element of the vector
exit_impl< next_, L >::type exit_
exit condition
v_transform_two_impl< H, arg0, next_, L, exit_::value, typename H< arg0, front_ >::type, Args... >::type type
Recursive call.
[v_transform metafunction]