8 #ifndef Navigation_TypeTraits_H
9 #define Navigation_TypeTraits_H
14 #if defined (KY_OS_WIIU)
15 #pragma ghs nowarning 236
26 enum { value =
false };
30 struct IsIntegral<bool>
32 enum { value =
true };
36 struct IsIntegral<unsigned char>
38 enum { value =
true };
42 struct IsIntegral<signed char>
44 enum { value =
true };
48 struct IsIntegral<char>
50 enum { value =
true };
56 enum { value =
true };
62 enum { value =
true };
68 enum { value =
true };
74 enum { value =
true };
80 enum { value =
true };
86 enum { value =
true };
94 enum { value =
false };
100 enum { value =
true };
106 enum { value =
true };
111 template <
typename T>
114 enum { value =
false };
120 enum { value =
true };
125 template <
typename T>
128 enum { value =
false };
131 template <
typename T>
134 enum { value =
true };
139 template <
typename T>
142 enum { value = IsIntegral<T>::value || IsFloat<T>::value };
147 template <
typename T>
150 enum { value = IsArithmetic<T>::value || IsVoid<T>::value };
154 template <
typename T>
155 struct HasTrivialConstructor
157 enum { value = IsArithmetic<T>::value || IsPointer<T>::value };
160 template <
typename T>
161 struct HasTrivialDestructor
163 enum { value = IsArithmetic<T>::value || IsPointer<T>::value };
170 template <
bool hasTrivialConstructor>
171 struct DefaultConstructorImpl;
174 struct DefaultConstructorImpl<false>
176 template <
typename T>
177 void PlacementNew(T* ptr) {
new (ptr) T; }
179 template <
typename T>
180 void PlacementNewRange(T* begin, T* end)
182 for (T* it = begin; it != end; ++it)
188 template <
typename Iterator,
typename T>
189 void ConstructRange(Iterator begin, Iterator end, T* buffer)
191 for (Iterator it = begin; it != end; ++it)
201 struct DefaultConstructorImpl<true>
203 template <
typename T>
204 void PlacementNew(T* ) {}
205 template <
typename T>
206 void PlacementNewRange(T* , T* ) {}
208 template <
typename T>
209 void ConstructRange(
const T* begin,
const T* end, T* buffer)
212 memcpy(buffer, begin, (end - begin) *
sizeof (T));
219 template <
bool hasTrivialDestructor>
220 struct DestructorImpl;
223 struct DestructorImpl<false>
225 template <
typename T>
231 template <
typename T>
232 void DestroyRange(T* begin, T* end)
234 for (T* it = begin; it != end; ++it)
242 struct DestructorImpl<true>
244 template <
typename T>
246 template <
typename T>
247 void DestroyRange(T* , T* ) {}
252 template <
typename T>
253 inline void CallDefaultConstructor(T* ptr)
255 Internal::DefaultConstructorImpl<HasTrivialConstructor<T>::value>().PlacementNew(ptr);
258 template <
typename T>
259 inline void CallDefaultConstructorRange(T* begin, T* end)
261 Internal::DefaultConstructorImpl<HasTrivialConstructor<T>::value>().PlacementNewRange(begin, end);
264 template <
typename Iterator,
typename T>
265 inline void ConstructRange(Iterator begin, Iterator end, T* buffer)
267 Internal::DefaultConstructorImpl<IsPointer<Iterator>::value && HasTrivialConstructor<T>::value>().ConstructRange(begin, end, buffer);
270 template <
typename T>
271 inline void CallDestructor(T* ptr)
273 Internal::DestructorImpl<HasTrivialDestructor<T>::value>().Destroy(ptr);
276 template <
typename T>
277 inline void DestroyRange(T* begin, T* end)
279 Internal::DestructorImpl<HasTrivialDestructor<T>::value>().DestroyRange(begin, end);
284 #endif // Navigation_TypeTraits_H
int KyInt32
Type used internally to represent a 32-bit integer.
Definition: types.h:35
unsigned __int64 KyUInt64
Type used internally to represent an unsigned 64-bit integer.
Definition: types.h:38
Definition: gamekitcrowddispersion.h:20
unsigned short KyUInt16
Type used internally to represent an unsigned 16-bit integer.
Definition: types.h:40
unsigned int KyUInt32
Type used internally to represent an unsigned 32-bit integer.
Definition: types.h:36
double KyFloat64
Type used internally to represent a 64-bit floating-point number.
Definition: types.h:44
__int64 KyInt64
Type used internally to represent a 64-bit integer.
Definition: types.h:37
short KyInt16
Type used internally to represent a 16-bit integer.
Definition: types.h:39
float KyFloat32
Type used internally to represent a 32-bit floating-point number.
Definition: types.h:43