diff options
Diffstat (limited to 'include/std/type_traits')
-rw-r--r-- | include/std/type_traits | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/include/std/type_traits b/include/std/type_traits new file mode 100644 index 00000000..8498a976 --- /dev/null +++ b/include/std/type_traits @@ -0,0 +1,63 @@ +#if !defined(_TYPE_TRAITS) +#define _TYPE_TRAITS + +namespace std +{ + /// integral_constant + template<typename _Tp, _Tp __v> + struct integral_constant + { + static const _Tp value = __v; + typedef _Tp value_type; + typedef integral_constant<_Tp, __v> type; + }; + + /// typedef for true_type + typedef integral_constant<bool, true> true_type; + + /// typedef for false_type + typedef integral_constant<bool, false> false_type; + + template<typename _Tp, _Tp __v> + const _Tp integral_constant<_Tp, __v>::value; + + /// remove_const + template<typename _Tp> + struct remove_const + { typedef _Tp type; }; + + /// remove_volatile + template<typename _Tp> + struct remove_volatile + { typedef _Tp type; }; + + /// remove_cv + template<typename _Tp> + struct remove_cv + { + typedef typename + remove_const<typename remove_volatile<_Tp>::type>::type type; + }; + + template<typename> struct _is_integral_type : public false_type { }; + template<> struct _is_integral_type<bool>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<char>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<signed char>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<unsigned char>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<short>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<unsigned short>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<int>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<unsigned int>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<long>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<unsigned long>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<long long>: public integral_constant<bool,true> {}; + template<> struct _is_integral_type<unsigned long long>: public integral_constant<bool,true> {}; + + /// is_integral + template<typename _Tp> + struct is_integral + : public integral_constant<bool, (_is_integral_type<typename + remove_cv<_Tp>::type>::value)> + { }; +} +#endif |