57 #ifndef BASE_TYPE_TRAITS_H_
58 #define BASE_TYPE_TRAITS_H_
65 _START_GOOGLE_NAMESPACE_
71 #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
87 template <
class T,
class U>
struct is_same;
88 #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
113 #ifdef HAVE_LONG_LONG
143 #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
177 template <
class T>
struct is_enum
179 is_same<T, void>::value ||
180 is_integral<T>::value ||
181 is_floating_point<T>::value ||
182 is_reference<T>::value ||
183 internal::is_class_or_union<T>::value,
201 template <
class T>
struct is_pod
203 is_floating_point<T>::value ||
204 #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
208 is_pointer<T>::value)> { };
209 template <class T> struct is_pod<const T> : is_pod<T> { };
210 template <class T> struct is_pod<volatile T> : is_pod<T> { };
211 template <class T> struct is_pod<const volatile T> : is_pod<T> { };
219 template <class T> struct has_trivial_constructor : is_pod<T> { };
220 template <class T, class U> struct has_trivial_constructor<std::pair<T, U> >
221 : integral_constant<bool,
222 (has_trivial_constructor<T>::value &&
223 has_trivial_constructor<U>::value)> { };
224 template <class A, int N> struct has_trivial_constructor<A[N]>
225 : has_trivial_constructor<A> { };
226 template <class T> struct has_trivial_constructor<const T>
227 : has_trivial_constructor<T> { };
234 template <class T> struct has_trivial_copy : is_pod<T> { };
235 template <class T, class U> struct has_trivial_copy<std::pair<T, U> >
236 : integral_constant<bool,
237 (has_trivial_copy<T>::value &&
238 has_trivial_copy<U>::value)> { };
239 template <class A, int N> struct has_trivial_copy<A[N]>
240 : has_trivial_copy<A> { };
241 template <class T> struct has_trivial_copy<const T> : has_trivial_copy<T> { };
247 template <class T> struct has_trivial_assign : is_pod<T> { };
248 template <class T, class U> struct has_trivial_assign<std::pair<T, U> >
249 : integral_constant<bool,
250 (has_trivial_assign<T>::value &&
251 has_trivial_assign<U>::value)> { };
252 template <class A, int N> struct has_trivial_assign<A[N]>
253 : has_trivial_assign<A> { };
260 template <class T> struct has_trivial_destructor : is_pod<T> { };
261 template <class T, class U> struct has_trivial_destructor<std::pair<T, U> >
262 : integral_constant<bool,
263 (has_trivial_destructor<T>::value &&
264 has_trivial_destructor<U>::value)> { };
265 template <class A, int N> struct has_trivial_destructor<A[N]>
266 : has_trivial_destructor<A> { };
267 template <class T> struct has_trivial_destructor<const T>
268 : has_trivial_destructor<T> { };
271 template<typename T> struct remove_const { typedef T type; };
272 template<typename T> struct remove_const<T const> { typedef T type; };
273 template<typename T> struct remove_volatile { typedef T type; };
274 template<typename T> struct remove_volatile<T volatile> { typedef T type; };
275 template<typename T> struct remove_cv {
276 typedef typename remove_const<typename remove_volatile<T>::type>::type type;
281 template<typename T> struct remove_reference { typedef T type; };
282 template<typename T> struct remove_reference<T&> { typedef T type; };
284 template <typename T> struct add_reference { typedef T& type; };
285 template <typename T> struct add_reference<T&> { typedef T& type; };
288 template<typename T> struct remove_pointer { typedef T type; };
289 template<typename T> struct remove_pointer<T*> { typedef T type; };
290 template<typename T> struct remove_pointer<T* const> { typedef T type; };
291 template<typename T> struct remove_pointer<T* volatile> { typedef T type; };
292 template<typename T> struct remove_pointer<T* const volatile> {
296 template<typename T, typename U> struct is_same : public false_type { };
297 template<typename T> struct is_same<T, T> : public true_type { };
300 #if !defined(_MSC_VER) && !(defined(__GNUC__) && __GNUC__ <= 3)
312 template <typename From, typename To>
313 struct ConvertHelper {
314 static small_ Test(To);
315 static big_ Test(...);
316 static From Create();
321 template <typename From, typename To>
322 struct is_convertible
323 : integral_constant<bool,
324 sizeof(internal::ConvertHelper<From, To>::Test(
325 internal::ConvertHelper<From, To>::Create()))
330 _END_GOOGLE_NAMESPACE_
336 #define DECLARE_POD(TypeName) typedef int Dummy_Type_For_DECLARE_POD
337 #define DECLARE_NESTED_POD(TypeName) DECLARE_POD(TypeName)
338 #define PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT(TemplateName) \
339 typedef int Dummy_Type_For_PROPAGATE_POD_FROM_TEMPLATE_ARGUMENT
340 #define ENFORCE_POD(TypeName) typedef int Dummy_Type_For_ENFORCE_POD
Definition: template_util.h:75
Definition: type_traits.h:155
_START_GOOGLE_NAMESPACE_ typedef char small_
Definition: template_util.h:57
Definition: type_traits.h:68
Definition: type_traits.h:80
Definition: type_traits.h:73
Definition: type_traits.h:86
Definition: type_traits.h:89
Definition: type_traits.h:83
Definition: type_traits.h:76
Definition: type_traits.h:82
Definition: type_traits.h:81
Definition: type_traits.h:85
static const bool value
Definition: type_traits.h:150
Definition: type_traits.h:79
Definition: type_traits.h:77
static small_ tester(void(U::*)())
Definition: type_traits.h:67
Definition: type_traits.h:78
Definition: type_traits.h:87
Definition: type_traits.h:147
Definition: type_traits.h:69
Definition: template_util.h:59
Definition: type_traits.h:84
Definition: type_traits.h:75