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
common.hpp
1 #ifndef COMMON_HPP
2 #define COMMON_HPP
3 
4 #include <type_traits>
5 #include <random>
6 #include "memory/memory.hpp"
7 
8 namespace std
9 {
10  // We need the definition of std::to_string that work on string
11 
12  inline static std::string to_string(std::string s)
13  {
14  return s;
15  }
16 }
17 
18 
19 // Compile time array functor needed to generate array at compile-time of type
20 // {0,0,0,0,0,.....}
21 // {3,3,3,3,3,3,.....}
22 
23  template<size_t index, size_t N> struct Fill_three {
24  enum { value = 3 };
25  };
26 
27  template<size_t index, size_t N> struct Fill_zero {
28  enum { value = 0 };
29  };
30 
31  template<size_t index, size_t N> struct Fill_two {
32  enum { value = 2 };
33  };
34 
35  template<size_t index, size_t N> struct Fill_one {
36  enum { value = 1 };
37  };
38 
40 template<typename> struct Void
41 {
43  typedef void type;
44 };
45 
46 template<typename T, typename Sfinae = void>
47 struct has_attributes: std::false_type {};
48 
49 
61 template<typename T>
62 struct has_attributes<T, typename Void<decltype( T::attributes::name[0] )>::type> : std::true_type
63 {};
64 
65 template<typename T, typename Sfinae = void>
66 struct has_typedef_type: std::false_type {};
67 
78 template<typename T>
79 struct has_typedef_type<T, typename Void< typename T::type>::type> : std::true_type
80 {};
81 
82 template<typename T, typename Sfinae = void>
83 struct has_data: std::false_type {};
84 
94 template<typename T>
95 struct has_data<T, typename Void<decltype( T::data )>::type> : std::true_type
96 {};
97 
98 template<typename T, typename Sfinae = void>
99 struct has_posMask: std::false_type {};
100 
110 template<typename T>
111 struct has_posMask<T, typename Void<decltype( T::stag_mask )>::type> : std::true_type
112 {};
113 
130 template<bool cond, typename T>
132 {
133  enum
134  {
135  value = std::is_same<decltype(T().data),typename T::type>::value
136  };
137 };
138 
139 
140 template<typename T>
142 {
143  enum
144  {
145  value = false
146  };
147 };
148 
149 
150 template<typename T, typename Sfinae = void>
151 struct has_noPointers: std::false_type {};
152 
153 
165 template<typename T>
166 struct has_noPointers<T, typename Void<decltype( T::noPointers() )>::type> : std::true_type
167 {};
168 
181 template<typename ObjType, typename Sfinae = void>
182 struct has_pack: std::false_type {};
183 
184 template<typename ObjType>
185 struct has_pack<ObjType, typename Void<decltype( ObjType::pack() )>::type> : std::true_type
186 {};
187 
188 
201 template<typename ObjType, typename Sfinae = void>
202 struct has_packRequest: std::false_type {};
203 
204 template<typename ObjType>
205 struct has_packRequest<ObjType, typename Void<decltype( ObjType::packRequest() )>::type> : std::true_type
206 {};
207 
208 
221 template<typename ObjType, typename Sfinae = void>
222 struct has_packMem: std::false_type {};
223 
232 template<typename ObjType>
233 struct has_packMem<ObjType, typename Void<decltype( ObjType::packMem() )>::type> : std::true_type
234 {};
235 
246 template<typename T, bool = is_typedef_and_data_same<has_typedef_type<T>::value && has_data<T>::value,T>::value>
247 struct is_openfpm_native : std::false_type
248 {};
249 
250 
251 template<typename T>
252 struct is_openfpm_native<T,true> : std::true_type
253 {};
254 
255 #endif
has_Pack check if a type has defined a method called Pack
Definition: common.hpp:182
check if T::type and T.data has the same type
Definition: common.hpp:131
has_packRequest check if a type has defined a method called packRequest
Definition: common.hpp:202
is_openfpm_native check if a type is an openfpm native structure type
Definition: common.hpp:247
Void structure.
Definition: common.hpp:40
has_calculateMem check if a type has defined a method called calculateMem
Definition: common.hpp:222
void type
define void type
Definition: common.hpp:43