📄 type_traits
字号:
template<typename _Tp> struct has_trivial_destructor : public integral_constant<bool, is_pod<_Tp>::value> { }; template<typename _Tp> struct has_nothrow_constructor : public integral_constant<bool, is_pod<_Tp>::value> { }; template<typename _Tp> struct has_nothrow_copy : public integral_constant<bool, is_pod<_Tp>::value> { }; template<typename _Tp> struct has_nothrow_assign : public integral_constant<bool, is_pod<_Tp>::value> { }; template<typename> struct has_virtual_destructor : public false_type { }; template<typename> struct is_signed : public false_type { }; _DEFINE_SPEC(0, is_signed, signed char, true) _DEFINE_SPEC(0, is_signed, short, true) _DEFINE_SPEC(0, is_signed, int, true) _DEFINE_SPEC(0, is_signed, long, true) _DEFINE_SPEC(0, is_signed, long long, true) template<typename> struct is_unsigned : public false_type { }; _DEFINE_SPEC(0, is_unsigned, unsigned char, true) _DEFINE_SPEC(0, is_unsigned, unsigned short, true) _DEFINE_SPEC(0, is_unsigned, unsigned int, true) _DEFINE_SPEC(0, is_unsigned, unsigned long, true) _DEFINE_SPEC(0, is_unsigned, unsigned long long, true) template<typename _Tp> struct alignment_of : public integral_constant<std::size_t, __alignof__(_Tp)> { }; template<typename> struct rank : public integral_constant<std::size_t, 0> { }; template<typename _Tp, std::size_t _Size> struct rank<_Tp[_Size]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; template<typename _Tp> struct rank<_Tp[]> : public integral_constant<std::size_t, 1 + rank<_Tp>::value> { }; template<typename, unsigned> struct extent : public integral_constant<std::size_t, 0> { }; template<typename _Tp, unsigned _Uint, std::size_t _Size> struct extent<_Tp[_Size], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? _Size : extent<_Tp, _Uint - 1>::value> { }; template<typename _Tp, unsigned _Uint> struct extent<_Tp[], _Uint> : public integral_constant<std::size_t, _Uint == 0 ? 0 : extent<_Tp, _Uint - 1>::value> { }; /// @brief relationships between types [4.6]. template<typename, typename> struct is_same : public false_type { }; template<typename _Tp> struct is_same<_Tp, _Tp> : public true_type { }; // See Daveed Vandevoorde explanation in http://tinyurl.com/502f. // Also see Rani Sharoni in http://tinyurl.com/6jvyq. template<typename _Base, typename _Derived, bool = (!__is_union_or_class<_Base>::value || !__is_union_or_class<_Derived>::value || is_same<_Base, _Derived>::value)> struct __is_base_of_helper : public __sfinae_types { private: typedef typename remove_cv<_Base>::type _NoCv_Base; typedef typename remove_cv<_Derived>::type _NoCv_Derived; template<typename _Up> static __one __test(_NoCv_Derived&, _Up); static __two __test(_NoCv_Base&, int); struct _Conv { operator _NoCv_Derived&(); operator _NoCv_Base&() const; }; public: static const bool __value = sizeof(__test(_Conv(), 0)) == 1; }; template<typename _Base, typename _Derived> struct __is_base_of_helper<_Base, _Derived, true> { static const bool __value = is_same<_Base, _Derived>::value; }; template<typename _Base, typename _Derived> struct is_base_of : public integral_constant<bool, __is_base_of_helper<_Base, _Derived>::__value> { }; template<typename _From, typename _To> struct __is_convertible_simple : public __sfinae_types { private: static __one __test(_To); static __two __test(...); static _From __makeFrom(); public: static const bool __value = sizeof(__test(__makeFrom())) == 1; }; template<typename _Tp> struct __is_int_or_cref { typedef typename remove_reference<_Tp>::type __rr_Tp; static const bool __value = (is_integral<_Tp>::value || (is_integral<__rr_Tp>::value && is_const<__rr_Tp>::value && !is_volatile<__rr_Tp>::value)); }; template<typename _From, typename _To, bool = (is_void<_From>::value || is_void<_To>::value || is_function<_To>::value || is_array<_To>::value // This special case is here only to avoid warnings. || (is_floating_point<typename remove_reference<_From>::type>::value && __is_int_or_cref<_To>::__value))> struct __is_convertible_helper { // "An imaginary lvalue of type From...". static const bool __value = (__is_convertible_simple<typename add_reference<_From>::type, _To>::__value); }; template<typename _From, typename _To> struct __is_convertible_helper<_From, _To, true> { static const bool __value = (is_void<_To>::value || (__is_int_or_cref<_To>::__value && !is_void<_From>::value)); }; template<typename _From, typename _To> struct is_convertible : public integral_constant<bool, __is_convertible_helper<_From, _To>::__value> { }; /// @brief const-volatile modifications [4.7.1]. template<typename _Tp> struct remove_const { typedef _Tp type; }; template<typename _Tp> struct remove_const<_Tp const> { typedef _Tp type; }; template<typename _Tp> struct remove_volatile { typedef _Tp type; }; template<typename _Tp> struct remove_volatile<_Tp volatile> { typedef _Tp type; }; template<typename _Tp> struct remove_cv { typedef typename remove_const<typename remove_volatile<_Tp>::type>::type type; }; template<typename _Tp> struct add_const { typedef _Tp const type; }; template<typename _Tp> struct add_volatile { typedef _Tp volatile type; }; template<typename _Tp> struct add_cv { typedef typename add_const<typename add_volatile<_Tp>::type>::type type; }; /// @brief reference modifications [4.7.2]. template<typename _Tp> struct remove_reference { typedef _Tp type; }; template<typename _Tp> struct remove_reference<_Tp&> { typedef _Tp type; }; template<typename _Tp> struct add_reference { typedef _Tp& type; }; template<typename _Tp> struct add_reference<_Tp&> { typedef _Tp& type; }; /// @brief array modififications [4.7.3]. template<typename _Tp> struct remove_extent { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_extent<_Tp[_Size]> { typedef _Tp type; }; template<typename _Tp> struct remove_extent<_Tp[]> { typedef _Tp type; }; template<typename _Tp> struct remove_all_extents { typedef _Tp type; }; template<typename _Tp, std::size_t _Size> struct remove_all_extents<_Tp[_Size]> { typedef typename remove_all_extents<_Tp>::type type; }; template<typename _Tp> struct remove_all_extents<_Tp[]> { typedef typename remove_all_extents<_Tp>::type type; }; /// @brief pointer modifications [4.7.4].#undef _DEFINE_SPEC_BODY#define _DEFINE_SPEC_BODY(_Value) \ { typedef _Tp type; }; template<typename _Tp> struct remove_pointer { typedef _Tp type; }; _DEFINE_SPEC(1, remove_pointer, _Tp*, false) template<typename _Tp> struct add_pointer { typedef typename remove_reference<_Tp>::type* type; }; /// @brief other transformations [4.8]. // Due to c++/19163 and c++/17743, for the time being we cannot use // the correct, neat implementation :-( // // template<std::size_t _Len, std::size_t _Align> // struct aligned_storage // { typedef char type[_Len] __attribute__((__aligned__(_Align))); } // // Temporary workaround, useful for Align up to 32: template<std::size_t, std::size_t> struct aligned_storage { }; template<std::size_t _Len> struct aligned_storage<_Len, 1> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(1))); }; }; template<std::size_t _Len> struct aligned_storage<_Len, 2> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(2))); }; }; template<std::size_t _Len> struct aligned_storage<_Len, 4> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(4))); }; }; template<std::size_t _Len> struct aligned_storage<_Len, 8> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(8))); }; }; template<std::size_t _Len> struct aligned_storage<_Len, 16> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(16))); }; }; template<std::size_t _Len> struct aligned_storage<_Len, 32> { union type { unsigned char __data[_Len]; char __align __attribute__((__aligned__(32))); }; };#undef _DEFINE_SPEC_0_HELPER#undef _DEFINE_SPEC_1_HELPER#undef _DEFINE_SPEC_2_HELPER#undef _DEFINE_SPEC#undef _DEFINE_SPEC_BODY}}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -