OpenFPM_pdata  4.1.0
Project that contain the implementation of distributed structures
map_vector_std_util.hpp
1 /*
2  * map_vector_std_util.hpp
3  *
4  * Created on: May 14, 2016
5  * Author: i-bird
6  */
7 
8 #ifndef OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_UTIL_HPP_
9 #define OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_UTIL_HPP_
10 
11 #include "util/common.hpp"
12 
18 template<bool,typename T, typename S>
20 {
29  static inline void push_back(std::vector<T> & base, const S & obj)
30  {
31 #ifndef DISABLE_ALL_RTTI
32  std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;
33 #endif
34  }
35 };
36 
42 template<typename T, typename S>
43 struct push_back_op_neste<true,T,S>
44 {
45 
54  static inline void push_back(std::vector<T> & base, const S & obj)
55  {
56  base.push_back(T());
57  base[base.size()-1] = obj;
58  }
59 };
60 
66 template<bool,typename T, typename S>
68 {
69 
78  static inline void push_back(std::vector<T> & base, const S & obj)
79  {
80 #ifndef DISABLE_ALL_RTTI
81  std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;
82 #endif
83  }
84 };
85 
86 template<typename T, typename S>
87 struct push_back_std_op_neste<true,T,S>
88 {
89  static inline void push_back(std::vector<T> & base, const S & obj)
90  {
91  base.reserve(base.size() + obj.size());
92  for (size_t i = 0 ; i < obj.size() ; i++)
93  {
94  base.push_back(obj.get(i));
95  }
96  }
97 };
98 
99 template<bool is_t, bool is_s,typename T, typename S>
101 {
102  static inline void push_back(std::vector<T> & base, const S & obj)
103  {
104 #ifndef DISABLE_ALL_RTTI
105  std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;
106 #endif
107  }
108 };
109 
110 template<typename T, typename S>
111 struct push_back_op<false,false,T,S>
112 {
113  static inline void push_back(std::vector<T> & base, const S & obj)
114  {
115  base.push_back(obj);
116  }
117 };
118 
119 template<typename T, typename S>
120 struct push_back_op<false,true,T,S>
121 {
122  static inline void push_back(std::vector<T> & base, const S & obj)
123  {
125  }
126 };
127 
128 
129 
130 template<typename T, typename S>
131 struct push_back_op<true,true,T,S>
132 {
133  static inline void push_back(std::vector<T> & base, const S & obj)
135  std::is_same<typename T::value_type,typename S::value_type>::value,T,S>::push_back(base,obj);}
136 };
137 
138 
139 template<bool has_base, typename base_obj, typename v_obj>
140 struct base_copy
141 {
142  static inline void copy(base_obj & base, const v_obj & obj)
143  {
144  base.clear();
145  base.resize(obj.size());
146 
147  for (size_t i = 0 ; i < obj.size() ; i++)
148  {
149  base.get(i) = obj.get(i);
150  }
151  }
152 };
153 
154 template<typename base_obj, typename v_obj>
155 struct base_copy<true,base_obj,v_obj>
156 {
157  static inline void copy(base_obj & base, const v_obj & obj)
158  {
159  base = obj.base;
160  }
161 };
162 
163 template<typename T, typename Sfinae = void>
164 struct has_base_to_copy: std::false_type {};
165 
175 template<typename T>
176 struct has_base_to_copy<T, typename Void< typename T::base_to_copy >::type > : std::true_type
177 {};
178 
179 #endif /* OPENFPM_DATA_SRC_VECTOR_MAP_VECTOR_STD_UTIL_HPP_ */
static void push_back(std::vector< T > &base, const S &obj)
Push_back on a vector.
pack/add function selector
Void structure.
Definition: common.hpp:73
static void push_back(std::vector< T > &base, const S &obj)
push_back
static void push_back(std::vector< T > &base, const S &obj)
push_back
pack/add function selector