gwnavruntime/base/typetraits.h Source File
Go to the documentation of this file.
21 enum { value =
false };
25 struct IsIntegral<bool>
27 enum { value =
true };
31 struct IsIntegral<unsigned char>
33 enum { value =
true };
37 struct IsIntegral<signed char>
39 enum { value =
true };
43 struct IsIntegral<char>
45 enum { value =
true };
51 enum { value =
true };
57 enum { value =
true };
63 enum { value =
true };
69 enum { value =
true };
75 enum { value =
true };
81 enum { value =
true };
89 enum { value =
false };
95 enum { value =
true };
101 enum { value =
true };
106 template <
typename T>
109 enum { value =
false };
115 enum { value =
true };
120 template <
typename T>
123 enum { value =
false };
126 template <
typename T>
129 enum { value =
true };
134 template <
typename T>
137 enum { value = IsIntegral<T>::value || IsFloat<T>::value };
142 template <
typename T>
145 enum { value = IsArithmetic<T>::value || IsVoid<T>::value };
149 template <
typename T>
150 struct HasTrivialConstructor
152 enum { value = IsArithmetic<T>::value || IsPointer<T>::value };
155 template <
typename T>
156 struct HasTrivialDestructor
158 enum { value = IsArithmetic<T>::value || IsPointer<T>::value };
165 template <
bool hasTrivialConstructor>
166 struct DefaultConstructorImpl;
169 struct DefaultConstructorImpl<false>
171 template <
typename T>
172 void PlacementNew(T* ptr) {
new (ptr) T; }
174 template <
typename T>
175 void PlacementNewRange(T* begin, T* end)
177 for (T* it = begin; it != end; ++it)
183 template <
typename Iterator,
typename T>
184 void ConstructRange(Iterator begin, Iterator end, T* buffer)
186 for (Iterator it = begin; it != end; ++it)
196 struct DefaultConstructorImpl<true>
198 template <
typename T>
199 void PlacementNew(T* ) {}
200 template <
typename T>
201 void PlacementNewRange(T* , T* ) {}
203 template <
typename T>
204 void ConstructRange(
const T* begin,
const T* end, T* buffer)
207 memcpy(buffer, begin, (end - begin) *
sizeof (T));
214 template <
bool hasTrivialDestructor>
215 struct DestructorImpl;
218 struct DestructorImpl<false>
220 template <
typename T>
226 template <
typename T>
227 void DestroyRange(T* begin, T* end)
229 for (T* it = begin; it != end; ++it)
237 struct DestructorImpl<true>
239 template <
typename T>
241 template <
typename T>
242 void DestroyRange(T* , T* ) {}
247 template <
typename T>
248 inline void CallDefaultConstructor(T* ptr)
250 Internal::DefaultConstructorImpl<HasTrivialConstructor<T>::value>().PlacementNew(ptr);
253 template <
typename T>
254 inline void CallDefaultConstructorRange(T* begin, T* end)
256 Internal::DefaultConstructorImpl<HasTrivialConstructor<T>::value>().PlacementNewRange(begin, end);
259 template <
typename Iterator,
typename T>
260 inline void ConstructRange(Iterator begin, Iterator end, T* buffer)
262 Internal::DefaultConstructorImpl<IsPointer<Iterator>::value && HasTrivialConstructor<T>::value>().ConstructRange(begin, end, buffer);
265 template <
typename T>
266 inline void CallDestructor(T* ptr)
268 Internal::DestructorImpl<HasTrivialDestructor<T>::value>().Destroy(ptr);
271 template <
typename T>
272 inline void DestroyRange(T* begin, T* end)
274 Internal::DestructorImpl<HasTrivialDestructor<T>::value>().DestroyRange(begin, end);
std::uint64_t KyUInt64
uint64_t
Definition: types.h:30
std::uint32_t KyUInt32
uint32_t
Definition: types.h:29
std::uint16_t KyUInt16
uint16_t
Definition: types.h:28
std::int64_t KyInt64
int64_t
Definition: types.h:25
The Autodesk Navigation namespace.
Definition: gamekitcrowddispersion.cpp:17
std::int32_t KyInt32
int32_t
Definition: types.h:24
double KyFloat64
double
Definition: types.h:33
std::int16_t KyInt16
int16_t
Definition: types.h:23
float KyFloat32
float
Definition: types.h:32