OpenFPM_data  0.1.0
Project that contain the implementation and interfaces for basic structure like vectors, grids, graph ... .
 All Data Structures Namespaces Functions Variables Typedefs Friends
meta_compare.hpp
1 /*
2  * meta_compare.hpp
3  *
4  * Created on: Oct 31, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_UTIL_META_COMPARE_HPP_
9 #define OPENFPM_DATA_SRC_UTIL_META_COMPARE_HPP_
10 
11 #include "compare_general.hpp"
12 
36 template<typename T>
37 struct meta_compare
38 {
39  static inline bool meta_compare_f(const T & src, const T & dst)
40  {
42  }
43 };
44 
46 template<typename T,size_t N1>
47 struct meta_compare<T[N1]>
48 {
49  static inline bool meta_compare_f(const T (& src)[N1], const T (& dst)[N1])
50  {
51  for (size_t i1 = 0 ; i1 < N1 ; i1++)
52  {
53  if (compare_general<T>::compare_general_f(src[i1],dst[i1]) == false)
54  return false;
55  }
56 
57  return true;
58  }
59 };
60 
62 template<typename T,size_t N1,size_t N2>
63 struct meta_compare<T[N1][N2]>
64 {
65  static inline bool meta_compare_f(const T (& src)[N1][N2], const T (& dst)[N1][N2])
66  {
67  for (size_t i1 = 0 ; i1 < N1 ; i1++)
68  {
69  for (size_t i2 = 0 ; i2 < N2 ; i2++)
70  {
71  if (compare_general<T>::compare_general_f(src[i1][i2],dst[i1][i2]) == false)
72  return false;
73  }
74  }
75 
76  return true;
77  }
78 };
79 
81 template<typename T,size_t N1,size_t N2,size_t N3>
82 struct meta_compare<T[N1][N2][N3]>
83 {
84  static inline bool meta_compare_f(const T (& src)[N1][N2][N3], const T (& dst)[N1][N2][N3])
85  {
86  for (size_t i1 = 0 ; i1 < N1 ; i1++)
87  {
88  for (size_t i2 = 0 ; i2 < N2 ; i2++)
89  {
90  for (size_t i3 = 0 ; i3 < N3 ; i3++)
91  {
92  if (compare_general<T>::compare_general_f(src[i1][i2][i3],dst[i1][i2][i3]) == false)
93  return false;
94  }
95  }
96  }
97 
98  return true;
99  }
100 };
101 
102 
103 
104 
105 #endif /* OPENFPM_DATA_SRC_UTIL_META_COMPARE_HPP_ */
This class compare general objects.
structure to copy aggregates
static bool compare_general_f(const T &src, const T &dst)
Spacialization when there is unknown compare method.