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
copy_general.hpp
1 /*
2  * aggregate_copy.hpp
3  *
4  * Created on: Oct 31, 2015
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_UTIL_COPY_GENERAL_HPP_
9 #define OPENFPM_DATA_SRC_UTIL_COPY_GENERAL_HPP_
10 
11 #include "util/common.hpp"
12 #include "util/util_debug.hpp"
13 #include "copy_compare_aggregates.hpp"
14 #include "util/for_each_ref.hpp"
15 #include <boost/mpl/range_c.hpp>
16 #include <iostream>
17 
23 template<typename T, unsigned int agg=2 * is_openfpm_native<T>::value + std::is_copy_assignable<T>::value>
25 {
32  inline copy_general(const T & src, T & dst)
33  {
34  std::cerr << "Error: " << __FILE__ << ":" << __LINE__ << demangle(typeid(T).name()) << " does not have an operator= and is not an aggregate or an openfpm native structure, copy is not possible" << "\n";
35  }
36 };
37 
42 template<typename T>
43 struct copy_general<T,1>
44 {
51  inline copy_general(const T & src, T & dst)
52  {
53  dst = src;
54  }
55 };
56 
57 template<typename T>
58 struct copy_general<T,2>
59 {
66  inline copy_general(const T & src, T & dst)
67  {
68  copy_aggregate<T> cp(src,dst);
69 
70  boost::mpl::for_each_ref<boost::mpl::range_c<int,0,T::max_prop>>(cp);
71  }
72 };
73 
74 template<typename T>
75 struct copy_general<T,3>
76 {
83  inline copy_general(const T & src, T & dst)
84  {
85  dst = src;
86  }
87 };
88 
89 #endif /* OPENFPM_DATA_SRC_UTIL_COPY_GENERAL_HPP_ */
Structure to copy aggregates.
copy_general(const T &src, T &dst)
copy objects that has an operator= (implicit or explicit)
structure to copy aggregates
copy_general(const T &src, T &dst)
copy objects that are aggregates but define an operator=
copy_general(const T &src, T &dst)
Spacialization when there is unknown copy method.
copy_general(const T &src, T &dst)
copy objects that are aggregates