OpenFPM_pdata  1.1.0
Project that contain the implementation of distributed structures
 All Data Structures Namespaces Functions Variables Typedefs Enumerations Friends Pages
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  std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;
32  }
33 };
34 
40 template<typename T, typename S>
41 struct push_back_op_neste<true,T,S>
42 {
43 
52  static inline void push_back(std::vector<T> & base, const S & obj)
53  {
54  base.push_back(T());
55  base[base.size()-1] = obj;
56  }
57 };
58 
64 template<bool,typename T, typename S>
66 {
67 
76  static inline void push_back(std::vector<T> & base, const S & obj)
77  {
78  std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;
79  }
80 };
81 
82 template<typename T, typename S>
83 struct push_back_std_op_neste<true,T,S>
84 {
85  static inline void push_back(std::vector<T> & base, const S & obj)
86  {
87  base.reserve(base.size() + obj.size());
88  for (size_t i = 0 ; i < obj.size() ; i++)
89  {
90  base.push_back(obj.get(i));
91  }
92  }
93 };
94 
95 template<bool is_t, bool is_s,typename T, typename S>
97 {
98  static inline void push_back(std::vector<T> & base, const S & obj)
99  {std::cerr << __FILE__ << ":" << __LINE__ << " error cannot push " << demangle(typeid(S).name()) << " into a vector of " << demangle(typeid(T).name()) << std::endl;}
100 };
101 
102 template<typename T, typename S>
103 struct push_back_op<false,false,T,S>
104 {
105  static inline void push_back(std::vector<T> & base, const S & obj)
106  {
107  base.push_back(obj);
108  }
109 };
110 
111 template<typename T, typename S>
112 struct push_back_op<false,true,T,S>
113 {
114  static inline void push_back(std::vector<T> & base, const S & obj)
115  {
117  }
118 };
119 
120 
121 
122 template<typename T, typename S>
123 struct push_back_op<true,true,T,S>
124 {
125  static inline void push_back(std::vector<T> & base, const S & obj)
127  std::is_same<typename T::value_type,typename S::value_type>::value,T,S>::push_back(base,obj);}
128 };
129 
130 
131 template<bool has_base, typename base_obj, typename v_obj>
132 struct base_copy
133 {
134  static inline void copy(base_obj & base, const v_obj & obj)
135  {
136  base.clear();
137  base.resize(obj.size());
138 
139  for (size_t i = 0 ; i < obj.size() ; i++)
140  {
141  base.get(i) = obj.get(i);
142  }
143  }
144 };
145 
146 template<typename base_obj, typename v_obj>
147 struct base_copy<true,base_obj,v_obj>
148 {
149  static inline void copy(base_obj & base, const v_obj & obj)
150  {
151  base = obj.base;
152  }
153 };
154 
155 template<typename T, typename Sfinae = void>
156 struct has_base_to_copy: std::false_type {};
157 
167 template<typename T>
168 struct has_base_to_copy<T, typename Void< typename T::base_to_copy >::type > : std::true_type
169 {};
170 
171 #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:63
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