OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
 
Loading...
Searching...
No Matches
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
40template<typename F,typename L>
41struct exit_impl : boost::mpl::equal_to<typename boost::mpl::distance<F,L>::type,boost::mpl::int_<0>>
42{};
43
51template<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
62
65};
66
67
69template<template<typename> class H,typename F,typename L,typename ...Args>
70struct v_transform_impl<H,F,L,true,Args...>
71{
73 typedef boost::fusion::vector<Args...> type;
74};
75
77template<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
106template<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
137template<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
148
151};
152
154template<template<typename,typename> class H,typename arg0, typename F,typename L,typename ...Args>
155struct v_transform_two_impl<H,arg0,F,L,true,Args...>
156{
158 typedef boost::fusion::vector<Args...> type;
159};
160
177template<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
209template<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
220
223};
224
226template<template<typename,typename> class H,typename arg0, typename F,typename L,typename ...Args>
227struct v_transform_two_v2_impl<H,arg0,F,L,true,Args...>
228{
230 typedef boost::fusion::vector<Args...> type;
231};
232
249template<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
281template <int... id>
283{
285 typedef boost::mpl::vector<boost::mpl::int_<id>...> type;
286};
287
289
290template <unsigned T1, unsigned int ...T>
292{
293 typedef boost::mpl::int_<T1> type;
294};
295
296template <unsigned int T1, unsigned int ...T>
298{
299 typedef typename last_variadic<T...>::type type;
300};
301
302template <unsigned int T1>
304{
305 typedef boost::mpl::int_<T1> type;
306};
307
308template <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
[v_transform metafunction]
Exit condition.
implementation of seq_traits
boost::mpl::end< Seq >::type last_
Last element.
exit_impl< first_, last_ >::type exit_
exit condition (first == last)
boost::mpl::begin< Seq >::type first_
first element
boost::mpl::vector< boost::mpl::int_< id >... > type
construct an mpl vector from the variadic
boost::fusion::vector< Args... > type
required transformed type
Recursive specialization of v_transform.
boost::mpl::next< F >::type next_
next element
exit_impl< next_, L >::type exit_
exit condition
v_transform_impl< H, next_, L, exit_::value, typenameH< front_ >::type, Args... >::type type
recursive call
boost::mpl::deref< F >::type front_
last element of the vector
boost::fusion::vector< Args... > type
Required type.
Recursive specialization of v_transform in case of metafunction with 2 argument.
boost::mpl::next< F >::type next_
next element of the vector
v_transform_two_impl< H, arg0, next_, L, exit_::value, typenameH< arg0, front_ >::type, Args... >::type type
Recursive call.
exit_impl< next_, L >::type exit_
exit condition
boost::mpl::deref< F >::type front_
last element of the vector
boost::fusion::vector< Args... > type
Required type.
Recursive specialization of v_transform in case of metafunction with 2 argument.
boost::mpl::next< F >::type next_
next element of the vector
v_transform_two_v2_impl< H, arg0, next_, L, exit_::value, typenameH< arg0, front_ >::type::type, Args... >::type type
Recursive call.
boost::mpl::deref< F >::type front_
last element of the vector
exit_impl< next_, L >::type exit_
exit condition
v_transform_two_v2_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
exit_impl< first, last >::type exit_
calculate the exit condition
seq_traits_impl< reversed_ >::first_ first
first element
seq_traits_impl< reversed_ >::last_ last
last element
seq_traits_impl< reversed_ >::first_ first
first element
boost::mpl::reverse< L >::type reversed_
reverse the sequence
v_transform_two_impl< H, arg0, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term
seq_traits_impl< reversed_ >::last_ last
last element
exit_impl< first, last >::type exit_
calculate the exit condition
seq_traits_impl< reversed_ >::last_ last
last element
boost::mpl::reverse< L >::type reversed_
reverse the sequence
seq_traits_impl< reversed_ >::first_ first
first element
exit_impl< first, last >::type exit_
calculate the exit condition
v_transform_impl< H, first, last, exit_::value >::type type
generate the boost::fusion::vector apply H on each term