📄 type_traits
字号:
struct is_reference
: _Cat_base<is_lvalue_reference<_Ty>::value
|| is_rvalue_reference<_Ty>::value>
{ // determine whether _Ty is a reference
};
#else /* _HAS_CPP0X */
// TEMPLATE CLASS is_reference
template<class _Ty>
struct is_reference
: false_type
{ // determine whether _Ty is a reference
};
template<class _Ty>
struct is_reference<_Ty&>
: true_type
{ // determine whether _Ty is a reference
};
#endif /* _HAS_CPP0X */
// TEMPLATE CLASS is_member_object_pointer
template<class _Ty>
struct _Is_member_object_pointer
: false_type
{ // determine whether _Ty is a pointer to member object
};
template<class _Ty1, class _Ty2>
struct _Is_member_object_pointer<_Ty1 _Ty2::*>
: _Cat_base<!_Is_memfunptr<_Ty1 _Ty2::*>::value>
{ // determine whether _Ty is a pointer to member object
};
template<class _Ty>
struct is_member_object_pointer
: _Is_member_object_pointer<typename remove_cv<_Ty>::type>
{ // determine whether _Ty is a pointer to member object
};
// TEMPLATE CLASS is_member_function_pointer
template<class _Ty>
struct is_member_function_pointer
: _Cat_base<_Is_memfunptr<typename remove_cv<_Ty>::type>::value>
{ // determine whether _Ty is a pointer to member function
};
// TEMPLATE CLASS is_pointer
template<class _Ty>
struct _Is_pointer
: false_type
{ // determine whether _Ty is a pointer
};
template<class _Ty>
struct _Is_pointer<_Ty *>
: _Cat_base<!is_member_object_pointer<_Ty *>::value
&& !is_member_function_pointer<_Ty *>::value>
{ // determine whether _Ty is a pointer
};
template<class _Ty>
struct is_pointer
: _Is_pointer<typename remove_cv<_Ty>::type>
{ // determine whether _Ty is a pointer
};
// TEMPLATE CLASS is_union
template<class _Ty>
struct is_union _IS_UNION(_Ty)
{ // determine whether _Ty is a union
};
// TEMPLATE CLASS is_class
template<class _Ty>
struct is_class _IS_CLASS(_Ty)
{ // determine whether _Ty is a class
};
// TEMPLATE CLASS is_function
template<class _Ty>
struct is_function
: _Cat_base<_Is_funptr<typename remove_cv<_Ty>::type *>::value>
{ // determine whether _Ty is a function
};
template<class _Ty>
struct is_function<_Ty&>
: false_type
{ // determine whether _Ty is a function
};
// TEMPLATE CLASS is_arithmetic
template<class _Ty>
struct is_arithmetic
: _Cat_base<is_integral<_Ty>::value
|| is_floating_point<_Ty>::value>
{ // determine whether _Ty is an arithmetic type
};
// TEMPLATE CLASS is_fundamental
template<class _Ty>
struct is_fundamental
: _Cat_base<is_arithmetic<_Ty>::value
|| is_void<_Ty>::value>
{ // determine whether _Ty is a fundamental type
};
// TEMPLATE CLASS is_object
template<class _Ty>
struct is_object
: _Cat_base<!is_function<_Ty>::value
&& !is_reference<_Ty>::value
&& !is_void<_Ty>::value>
{ // determine whether _Ty is an object type
};
// TEMPLATE CLASS is_convertible
template<class _From, class _To>
struct is_convertible _IS_CONVERTIBLE(_From, _To)
{ // determine whether _From is convertible to _To
};
// TEMPLATE CLASS is_enum
template<class _Ty>
struct is_enum _IS_ENUM(_Ty)
{ // determine whether _Ty is an enumerated type
};
// TEMPLATE CLASS is_compound
template<class _Ty>
struct is_compound
: _Cat_base<!is_fundamental<_Ty>::value>
{ // determine whether _Ty is a compound type
};
// TEMPLATE CLASS is_member_pointer
template<class _Ty>
struct is_member_pointer
: _Cat_base<is_member_object_pointer<_Ty>::value
|| is_member_function_pointer<_Ty>::value>
{ // determine whether _Ty is a pointer to member
};
// TEMPLATE CLASS is_scalar
template<class _Ty>
struct is_scalar
: _Cat_base<is_arithmetic<_Ty>::value
|| is_enum<_Ty>::value
|| is_pointer<_Ty>::value
|| is_member_pointer<_Ty>::value>
{ // determine whether _Ty is a scalar type
};
template<class _Ty>
struct is_scalar<_Ty&>
: false_type
{
};
// TEMPLATE CLASS is_const
template<class _Ty>
struct is_const
: _Cat_base<_Ptr_traits<_Ty *>::_Is_const
&& !is_function<_Ty>::value>
{ // determine whether _Ty is const qualified
};
template<class _Ty, unsigned int _Nx>
struct is_const<_Ty[_Nx]>
: false_type
{ // determine whether _Ty is const qualified
};
template<class _Ty, unsigned int _Nx>
struct is_const<const _Ty[_Nx]>
: true_type
{ // determine whether _Ty is const qualified
};
template<class _Ty>
struct is_const<_Ty&>
: false_type
{ // determine whether _Ty is const qualified
};
// TEMPLATE CLASS is_volatile
template<class _Ty>
struct is_volatile
: _Cat_base<_Ptr_traits<_Ty *>::_Is_volatile
&& !is_function<_Ty>::value>
{ // determine whether _Ty is volatile qualified
};
template<class _Ty>
struct is_volatile<_Ty&>
: false_type
{ // determine whether _Ty is volatile qualified
};
// TEMPLATE CLASS is_pod
template<class _Ty>
struct _Is_pod _IS_POD(_Ty)
{ // determine whether _Ty is a POD type
};
template<class _Ty>
struct is_pod
: _Is_pod<typename _STD tr1::remove_all_extents<_Ty>::type>
{ // determine whether _Ty is a POD type
};
// TEMPLATE CLASS is_empty
template<class _Ty>
struct is_empty _IS_EMPTY(_Ty)
{ // determine whether _Ty is an empty class
};
// TEMPLATE CLASS is_polymorphic
template<class _Ty>
struct is_polymorphic _IS_POLYMORPHIC(_Ty)
{ // determine whether _Ty is a polymorphic type
};
// TEMPLATE CLASS is_abstract
template<class _Ty>
struct is_abstract _IS_ABSTRACT(_Ty)
{ // determine whether _Ty is an abstract class
};
#if _HAS_CPP0X
// TEMPLATE CLASS is_standard_layout
template<class _Ty>
struct is_standard_layout _IS_STANDARD_LAYOUT(_Ty)
{ // determine whether _Ty is standard layout
};
// TEMPLATE CLASS is_trivial
template<class _Ty>
struct is_trivial _IS_TRIVIAL(_Ty)
{ // determine whether _Ty is trivial
};
#endif /* _HAS_CPP0X */
// TEMPLATE CLASS has_trivial_constructor -- retained
template<class _Ty>
struct has_trivial_constructor _HAS_TRIVIAL_CONSTRUCTOR(_Ty)
{ // determine whether _Ty has a trivial constructor
};
// TEMPLATE CLASS has_trivial_copy -- retained
template<class _Ty>
struct has_trivial_copy _HAS_TRIVIAL_COPY(_Ty)
{ // determine whether _Ty has a trivial copy constructor
};
#if _HAS_CPP0X
// TEMPLATE CLASS has_trivial_default_constructor
template<class _Ty>
struct has_trivial_default_constructor _HAS_TRIVIAL_CONSTRUCTOR(_Ty)
{ // determine whether _Ty has a trivial constructor
};
// TEMPLATE CLASS has_trivial_copy_constructor
template<class _Ty>
struct has_trivial_copy_constructor _HAS_TRIVIAL_COPY(_Ty)
{ // determine whether _Ty has a trivial copy constructor
};
#endif /* _HAS_CPP0X */
// TEMPLATE CLASS has_trivial_assign
template<class _Ty>
struct has_trivial_assign _HAS_TRIVIAL_ASSIGN(_Ty)
{ // determine whether _Ty has a trivial assignment operator
};
// TEMPLATE CLASS has_trivial_destructor
template<class _Ty>
struct has_trivial_destructor _HAS_TRIVIAL_DESTRUCTOR(_Ty)
{ // determine whether _Ty has a trivial destructor
};
// TEMPLATE CLASS has_nothrow_constructor -- retained
template<class _Ty>
struct has_nothrow_constructor _HAS_NOTHROW_CONSTRUCTOR(_Ty)
{ // determine whether _Ty has a nothrow constructor
};
// TEMPLATE CLASS has_nothrow_copy -- retained
template<class _Ty>
struct has_nothrow_copy _HAS_NOTHROW_COPY(_Ty)
{ // determine whether _Ty has a nothrow copy constructor
};
#if _HAS_CPP0X
// TEMPLATE CLASS has_nothrow_default_constructor
template<class _Ty>
struct has_nothrow_default_constructor _HAS_NOTHROW_CONSTRUCTOR(_Ty)
{ // determine whether _Ty has a nothrow constructor
};
// TEMPLATE CLASS has_nothrow_copy_constructor
template<class _Ty>
struct has_nothrow_copy_constructor _HAS_NOTHROW_COPY(_Ty)
{ // determine whether _Ty has a nothrow copy constructor
};
#endif /* _HAS_CPP0X */
// TEMPLATE CLASS has_nothrow_assign
template<class _Ty>
struct has_nothrow_assign _HAS_NOTHROW_ASSIGN(_Ty)
{ // determine whether _Ty has a nothrow assignment operator
};
// TEMPLATE CLASS has_virtual_destructor
template<class _Ty>
struct has_virtual_destructor _HAS_VIRTUAL_DESTRUCTOR(_Ty)
{ // determine whether _Ty has a virtaul destructor
};
// TEMPLATE CLASS is_signed
template<class _Ty>
struct _Has_signed_vals
: _Cat_base<(typename remove_cv<_Ty>::type)(-1)
< (typename remove_cv<_Ty>::type)(0)>
{ // integral type can represent negative values
};
template<class _Ty>
struct is_signed
: _Cat_base<is_floating_point<_Ty>::value || is_integral<_Ty>::value
&& _Has_signed_vals<
typename _If<is_integral<_Ty>::value, _Ty, int>::_Type>::value>
{ // determine whether _Ty is a signed type
};
// TEMPLATE CLASS is_unsigned
template<class _Ty>
struct is_unsigned
: _Cat_base<is_integral<_Ty>::value
&& !_Has_signed_vals<
typename _If<is_integral<_Ty>::value, _Ty, int>::_Type>::value>
{ // determine whether _Ty is an unsigned type
};
// TEMPLATE CLASS make_signed
template<class _Ty>
struct make_signed
{ // signed partner to _Ty
static const size_t _Bytes = sizeof (_Ty);
typedef typename _If<is_signed<_Ty>::value, _Ty,
typename _If<_Bytes <= sizeof (char), signed char,
typename _If<_Bytes <= sizeof (short), short,
typename _If<_Bytes <= sizeof (int), int,
typename _If<_Bytes <= sizeof (long), long,
_Longlong>::_Type>::_Type>::_Type>
::_Type>::_Type type;
};
// TEMPLATE CLASS make_unsigned
template<class _Ty>
struct make_unsigned
{ // unsigned partner to _Ty
static const size_t _Bytes = sizeof (_Ty);
typedef typename _If<is_unsigned<_Ty>::value, _Ty,
typename _If<_Bytes <= sizeof (char), unsigned char,
typename _If<_Bytes <= sizeof (short), unsigned short,
typename _If<_Bytes <= sizeof (int), unsigned int,
typename _If<_Bytes <= sizeof (long), unsigned long,
_ULonglong>::_Type>::_Type>::_Type>
::_Type>::_Type type;
};
// TEMPLATE CLASS alignment_of
template<class _Ty>
struct _Get_align
{ // struct used to determine alignemt of _Ty
_Ty _Elt0;
char _Elt1;
_Ty _Elt2;
};
#define _ALIGN_OF(ty) (sizeof(_Get_align<ty>) - 2 * sizeof(ty))
template<class _Ty>
struct alignment_of
: integral_constant<size_t, _ALIGN_OF(_Ty)>
{ // determine alignment of _Ty
};
template<class _Ty>
struct alignment_of<_Ty&>
: integral_constant<size_t, _ALIGN_OF(_Ty *)>
{ // assume references are aligned like pointers
};
// TEMPLATE CLASS aligned_storage
#define _FITS(ty) _Align == _ALIGN_OF(ty)
#define _NEXT_ALIGN(ty) \
typedef typename _Aligned<_Len, _Align, ty, _FITS(ty)>::_Type _Type
template<class _Ty, size_t _Len> union _Align_type
{ // union with size _Len bytes and alignment of _Ty
_Ty _Val;
char _Pad[_Len];
};
template<size_t _Len, size_t _Align, class _Ty, bool _Ok>
struct _Aligned;
template<size_t _Len, size_t _Align, class _Ty>
struct _Aligned<_Len, _Align, _Ty, true>
{ // define type with size _Len and alignment _Ty
typedef _Align_type<_Ty, _Len> _Type;
};
template<size_t _Len, size_t _Align>
struct _Aligned<_Len, _Align, long, false>
{ // define type with size _Len and alignment _Ty
typedef _Align_type<double, _Len> _Type;
};
template<size_t _Len, size_t _Align>
struct _Aligned<_Len, _Align, int, false>
{ // define type with size _Len and alignment _Ty
_NEXT_ALIGN(long);
};
template<size_t _Len, size_t _Align>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -