OpenFPM  5.2.0
Project that contain the implementation of distributed structures
storage_order.hpp
1 /*
2  * storage_order.hpp
3  *
4  * Created on: Jul 1, 2018
5  * Author: i-bird
6  */
7 
8 #ifndef STORAGE_ORDER_HPP_
9 #define STORAGE_ORDER_HPP_
10 
11 #include "types.hpp"
12 #include "array_openfpm.hpp"
13 #include "boost/multi_array/algorithm.hpp"
14 #include <boost/mpl/push_back.hpp>
15 #include <boost/mpl/vector.hpp>
16 #include <boost/mpl/at.hpp>
17 #include <algorithm>
18 #include <cstddef>
19 #include <functional>
20 #include <numeric>
21 #include <vector>
22 
23 namespace openfpm
24 {
25 
26 template<unsigned int NumDims, unsigned int n, typename T> struct c_storage_order;
27 template<unsigned int NumDims, unsigned int n, typename T> struct ofp_storage_order;
28 template<unsigned int NumDims, unsigned int n, typename T> struct fortran_storage_order;
29 
30 template<unsigned int NumDims, unsigned int n=NumDims-1, typename T=boost::mpl::vector<>>
32 {
33  typedef typename boost::mpl::push_back<typename c_storage_order<NumDims,n-1,T>::value, boost::mpl::int_<NumDims-1-n>>::type value;
34 };
35 
36 template <unsigned int NumDims, typename T>
37 struct c_storage_order<NumDims, 0, T>
38 {
39  typedef typename boost::mpl::push_back<T,boost::mpl::int_<NumDims-1>>::type value;
40 };
41 
42 template<unsigned int NumDims, unsigned int n=NumDims-1, typename T=boost::mpl::vector<>>
44 {
45  typedef typename boost::mpl::push_back<typename fortran_storage_order<NumDims,n-1,T>::value, boost::mpl::int_<n>>::type value;
46 };
47 
48 template <unsigned int NumDims, typename T>
49 struct fortran_storage_order<NumDims, 0, T>
50 {
51  typedef typename boost::mpl::push_back<T,boost::mpl::int_<0>>::type value;
52 };
53 
54 template<unsigned int NumDims, unsigned int n=NumDims-1, typename T=boost::mpl::vector<>>
56 {
57  typedef typename boost::mpl::push_back<typename ofp_storage_order<NumDims,n-1,T>::value, boost::mpl::int_<NumDims-n>>::type value;
58 };
59 
60 template <unsigned int NumDims, typename T>
61 struct ofp_storage_order<NumDims, 0, T>
62 {
63  typedef typename boost::mpl::push_back<T,boost::mpl::int_<0>>::type value;
64 };
65 
66 } // namespace openfpm
67 
68 
69 #endif /* STORAGE_ORDER_HPP_ */
convert a type into constant type
Definition: aggregate.hpp:302