OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
ct_array.hpp
1 /*
2  * ct_array.hpp
3  *
4  * Created on: Aug 21, 2014
5  * Author: Pietro Incardona
6  */
7 
8 
9 
18 #ifndef CT_ARRAY_HPP_
19 #define CT_ARRAY_HPP_
20 
21 
22 #include <boost/fusion/mpl.hpp>
23 
25 
26 template<int ...> struct index_tuple{};
27 
29 template<class T, int... args> struct ArrayHolder_indexes {
31  typedef index_tuple<args ... > type;
32 };
33 
35 template<class T,long int N, size_t orig_N, template<size_t,size_t> class F, int... args>
38  typedef typename generate_indexes_impl<T,N-1,orig_N, F, F<N,orig_N>::value, args...>::result result;
39 };
40 
42 template<class T, size_t orig_N, template<size_t,size_t> class F, int... args>
43 struct generate_indexes_impl<T,0,orig_N, F, args...> {
45  typedef typename ArrayHolder_indexes<T,F<0,orig_N>::value, args...>::type result;
46 };
47 
49 template<class T, size_t orig_N, template<size_t,size_t> class F, int... args>
50 struct generate_indexes_impl<T,-1,orig_N, F, args...> {
53 };
54 
68 template<class T, long int N, template<size_t,size_t> class F>
71  typedef typename generate_indexes_impl<T,N-1, N, F>::result result;
72 };
73 
75 
76 #ifndef COVERTY_SCAN
77 
79 template<class T, unsigned long... args> struct ArrayHolder_constexpr {
81  constexpr static T data[sizeof...(args)] = { args... };
82 };
83 
84 
86 template<class T,size_t N, size_t orig_N, template<size_t,size_t> class F, unsigned... args>
89  typedef typename generate_array_constexpr_impl<T,N-1,orig_N, F, F<N,orig_N>::value, args...>::result result;
90 };
91 
93 template<class T, size_t orig_N, template<size_t,size_t> class F, unsigned... args>
94 struct generate_array_constexpr_impl<T,0,orig_N, F, args...> {
97 };
98 
119 template<class T, size_t N, template<size_t,size_t> class F>
122  typedef typename generate_array_constexpr_impl<T,N-1, N, F>::result result;
123 };
124 
125 #endif
126 
128 
130 template<class T, unsigned long... args> struct ArrayHolder {
131  static const T data[sizeof...(args)];
132 };
133 
135 template<class T, unsigned long... args>
136 const T ArrayHolder<T,args...>::data[sizeof...(args)] = { args... };
137 
139 template<class T,size_t N, size_t orig_N, template<size_t,size_t> class F, unsigned... args>
142  typedef typename generate_array_impl<T,N-1,orig_N, F, F<N,orig_N>::value, args...>::result result;
143 };
144 
146 template<class T, size_t orig_N, template<size_t,size_t> class F, unsigned... args>
147 struct generate_array_impl<T,0,orig_N, F, args...> {
150 };
151 
170 template<class T, size_t N, template<size_t,size_t> class F>
172  typedef typename generate_array_impl<T,N-1, N, F>::result result;
173 };
174 
176 
178 template<class T, size_t N ,class F, unsigned... args>
181  typedef typename generate_array_vector_impl<T,N-1,F, boost::mpl::at<F,boost::mpl::int_<N> >::type::value , args...>::result result;
182 };
183 
185 template<class T, class F, unsigned... args>
186 struct generate_array_vector_impl<T,0, F, args...> {
189 };
190 
207 template<class T, class F>
211 };
212 
213 #endif
the array itself
Definition: ct_array.hpp:130
Generate the array specializing ArrayHolder.
Definition: ct_array.hpp:140
recursive meta-function to generate compile-time array
Definition: ct_array.hpp:87
ArrayHolder< T, F< 0, orig_N >::value, args... > result
compile-time array
Definition: ct_array.hpp:149
the array itself
Definition: ct_array.hpp:79
Main class to generate compile-time array.
Definition: ct_array.hpp:171
generate_array_constexpr_impl< T, N-1, N, F >::result result
meta-function to generate compile time array
Definition: ct_array.hpp:122
index_tuple< args ... > type
convert variadic into a tuple struct containing the list
Definition: ct_array.hpp:31
generate_indexes_impl< T, N-1, N, F >::result result
generate compile time array
Definition: ct_array.hpp:71
generate compile time index array
Definition: ct_array.hpp:36
Main class to generate an array from a boost::mpl::vector of numbers.
Definition: ct_array.hpp:208
Generate the array specializing ArrayHolder.
Definition: ct_array.hpp:179
Main class to generate constexpr compile-time array.
Definition: ct_array.hpp:120
generate_indexes_impl< T, N-1, orig_N, F, F< N, orig_N >::value, args... >::result result
Metafunction to generate indexes.
Definition: ct_array.hpp:38
static const T data[sizeof...(args)]
initialize the array from variadic template
Definition: ct_array.hpp:131
static constexpr T data[sizeof...(args)]
compile-time array
Definition: ct_array.hpp:81
ArrayHolder_constexpr< T, F< 0, orig_N >::value, args... > result
Compile-time array.
Definition: ct_array.hpp:96
generate_array_vector_impl< T, boost::mpl::size< F >::value-1, F >::result result
generate compile-time array vector
Definition: ct_array.hpp:210
ArrayHolder_indexes< T, F< 0, orig_N >::value, args... >::type result
generate the compile-time array
Definition: ct_array.hpp:45
These set of classes generate an array definition at compile-time.
Definition: ct_array.hpp:26
generate_array_impl< T, N-1, orig_N, F, F< N, orig_N >::value, args... >::result result
recursive meta-function to generate compile-time array
Definition: ct_array.hpp:142
ArrayHolder< T, boost::mpl::at< F, boost::mpl::int_< 0 > >::type::value, args... > result
compile-time array generation
Definition: ct_array.hpp:188
generate_array_vector_impl< T, N-1, F, boost::mpl::at< F, boost::mpl::int_< N > >::type::value, args... >::result result
recursive meta-function to generate compile-time array
Definition: ct_array.hpp:181
Main class to generate indexes data structure.
Definition: ct_array.hpp:69
the array itself
Definition: ct_array.hpp:29
generate_array_constexpr_impl< T, N-1, orig_N, F, F< N, orig_N >::value, args... >::result result
recursive meta-function to generate compile-time array
Definition: ct_array.hpp:89
[v_transform metafunction]