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
compare_general.hpp
1 /*
2  * compare_general.hpp
3  *
4  * Created on: Nov 1, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_UTIL_COMPARE_GENERAL_HPP_
9 #define OPENFPM_DATA_SRC_UTIL_COMPARE_GENERAL_HPP_
10 
11 
12 #include "util/common.hpp"
13 #include "util/util_debug.hpp"
14 #include "util/for_each_ref.hpp"
15 #include <boost/mpl/range_c.hpp>
16 
22 template<typename T, unsigned int agg=2 * is_openfpm_native<T>::value>
24 {
31  static inline bool compare_general_f(const T & src, const T & dst)
32  {
33  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << " " << demangle(typeid(T).name()) << " does not have an operator== and is not an aggregate or an openfpm native structure, comparation is not possible" << "\n";
34  return false;
35  }
36 };
37 
38 
39 template<typename T>
40 struct compare_general<T,2>
41 {
48  static inline bool compare_general_f(const T & src, const T & dst)
49  {
50  compare_aggregate<T> cp(src,dst);
51 
52  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(cp);
53 
54  return cp.result();
55  }
56 };
57 
58 template<typename T>
59 struct compare_general<T,0>
60 {
67  static inline bool compare_general_f(const T & src, const T & dst)
68  {
69  return dst == src;
70  }
71 };
72 
73 
74 #endif /* OPENFPM_DATA_SRC_UTIL_COMPARE_GENERAL_HPP_ */
Structure to compare aggregates.
bool result()
Returh the result of the comparison.
static bool compare_general_f(const T &src, const T &dst)
compare objects that are aggregates
static bool compare_general_f(const T &src, const T &dst)
compare objects that are aggregates but define an operator=
structure to copy aggregates
static bool compare_general_f(const T &src, const T &dst)
Spacialization when there is unknown compare method.