| 1 | /* |
| 2 | * mul_array_extents.hpp |
| 3 | * |
| 4 | * Created on: Dec 2, 2015 |
| 5 | * Author: i-bird |
| 6 | */ |
| 7 | |
| 8 | #ifndef OPENFPM_DATA_SRC_UTIL_MUL_ARRAY_EXTENTS_HPP_ |
| 9 | #define OPENFPM_DATA_SRC_UTIL_MUL_ARRAY_EXTENTS_HPP_ |
| 10 | |
| 11 | /*! \brief Struct that give functionalities on array extensions |
| 12 | * |
| 13 | * # Multiplication of all the extents |
| 14 | * \snippet util_test.hpp Usage mul_array_extents |
| 15 | * |
| 16 | */ |
| 17 | template<typename T> |
| 18 | struct array_extents |
| 19 | { |
| 20 | static inline size_t mul() |
| 21 | { |
| 22 | return 1; |
| 23 | } |
| 24 | }; |
| 25 | |
| 26 | /*! \brief Struct that give functionalities on array extensions |
| 27 | * |
| 28 | * # Multiplication of all the extents |
| 29 | * \snippet util_test.hpp Usage mul_array_extents |
| 30 | * |
| 31 | */ |
| 32 | template<typename T,size_t N1> |
| 33 | struct array_extents<T[N1]> |
| 34 | { |
| 35 | static inline size_t mul() |
| 36 | { |
| 37 | return N1; |
| 38 | } |
| 39 | }; |
| 40 | |
| 41 | /*! \brief Struct that give functionalities on array extensions |
| 42 | * |
| 43 | * # Multiplication of all the extents |
| 44 | * \snippet util_test.hpp Usage mul_array_extents |
| 45 | * |
| 46 | */ |
| 47 | template<typename T,size_t N1,size_t N2> |
| 48 | struct array_extents<T[N1][N2]> |
| 49 | { |
| 50 | static inline size_t mul() |
| 51 | { |
| 52 | return N1 * N2; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | /*! \brief Struct that give functionalities on array extensions |
| 57 | * |
| 58 | * # Multiplication of all the extents |
| 59 | * \snippet util_test.hpp Usage mul_array_extents |
| 60 | * |
| 61 | */ |
| 62 | template<typename T,size_t N1,size_t N2,size_t N3> |
| 63 | struct array_extents<T[N1][N2][N3]> |
| 64 | { |
| 65 | static inline size_t mul() |
| 66 | { |
| 67 | return N1 * N2 * N3; |
| 68 | } |
| 69 | }; |
| 70 | |
| 71 | |
| 72 | #endif /* OPENFPM_DATA_SRC_UTIL_MUL_ARRAY_EXTENTS_HPP_ */ |
| 73 | |