📄 type_traits
字号:
struct _Aligned<_Len, _Align, short, false>
{ // define type with size _Len and alignment _Ty
_NEXT_ALIGN(int);
};
template<size_t _Len, size_t _Align>
struct _Aligned<_Len, _Align, char, false>
{ // define type with size _Len and alignment _Ty
_NEXT_ALIGN(short);
};
template<size_t _Len, size_t _Align>
struct aligned_storage
{ // define type with size _Len and alignment _Ty
typedef typename _Aligned<_Len, _Align, char, _FITS(char)>::_Type type;
};
#undef _FITS
#undef _NEXT_ALIGN
#undef _ALIGN_OF
// TEMPLATE CLASS rank
template<class _Ty>
struct rank
: integral_constant<size_t, 0>
{ // determine number of dimensions of array _Ty
};
template<class _Ty, unsigned int _Ix>
struct rank<_Ty[_Ix]>
: integral_constant<size_t, rank<_Ty>::value + 1>
{ // determine number of dimensions of array _Ty
};
template<class _Ty>
struct rank<_Ty[]>
: integral_constant<size_t, rank<_Ty>::value + 1>
{ // determine number of dimensions of array _Ty
};
// TEMPLATE CLASS extent
template<class _Ty, unsigned int _Nx>
struct _Extent
: integral_constant<size_t, 0>
{ // determine extent of dimension _Nx of array _Ty
};
template<class _Ty, unsigned int _Ix>
struct _Extent<_Ty[_Ix], 0>
: integral_constant<size_t, _Ix>
{ // determine extent of dimension _Nx of array _Ty
};
template<class _Ty, unsigned int _Nx, unsigned int _Ix>
struct _Extent<_Ty[_Ix], _Nx>
: _Extent<_Ty, _Nx - 1>
{ // determine extent of dimension _Nx of array _Ty
};
template<class _Ty, unsigned int _Nx>
struct _Extent<_Ty[], _Nx>
: _Extent<_Ty, _Nx - 1>
{ // determine extent of dimension _Nx of array _Ty
};
template<class _Ty, unsigned int _Nx = 0>
struct extent
: _Extent<_Ty, _Nx>
{ // determine extent of dimension _Nx of array _Ty
};
// TEMPLATE CLASS is_same
template<class _Ty1, class _Ty2>
struct is_same
: false_type
{ // determine whether _Ty1 and _Ty2 are the same type
};
template<class _Ty1>
struct is_same<_Ty1, _Ty1>
: true_type
{ // determine whether _Ty1 and _Ty2 are the same type
};
// TEMPLATE CLASS is_base_of
template<class _Base, class _Der>
struct is_base_of _IS_BASE_OF(_Base, _Der)
{ // determine whether _Base is a base of or the same as _Der
};
// #if _HAS_CPP0X handy for non CPP0X too
// TEMPLATE CLASS decay
template<class _Ty>
struct decay
{ // determines decayed version of _Ty
typedef typename remove_reference<_Ty>::type _Ty1;
typedef typename _If<is_array<_Ty1>::value,
typename remove_extent<_Ty1>::type *,
typename _If<is_function<_Ty1>::value,
typename add_pointer<_Ty1>::type,
typename remove_cv<_Ty1>::type>::_Type>::_Type type;
};
// TEMPLATE CLASS enable_if
template<bool _Test,
class _Type = void>
struct enable_if
{ // type is undefined for assumed !_Test
};
template<class _Type>
struct enable_if<true, _Type>
{ // type is _Type for _Test
typedef _Type type;
};
// TEMPLATE CLASS conditional
template<bool _Test,
class _Ty1,
class _Ty2>
struct conditional
{ // type is _Ty2 for assumed !_Test
typedef _Ty2 type;
};
template<class _Ty1,
class _Ty2>
struct conditional<true, _Ty1, _Ty2>
{ // type is _Ty1 for _Test
typedef _Ty1 type;
};
// #endif /* _HAS_CPP0X */
} // namespace tr1
#if _HAS_TR1_IMPORTS
using tr1::add_const;
using tr1::add_cv;
using tr1::add_pointer;
using tr1::add_lvalue_reference;
using tr1::add_reference; // retained
using tr1::add_rvalue_reference;
using tr1::add_volatile;
using tr1::aligned_storage;
using tr1::alignment_of;
using tr1::conditional;
using tr1::decay;
using tr1::enable_if;
using tr1::extent;
using tr1::false_type;
using tr1::has_nothrow_assign;
using tr1::has_nothrow_constructor; // retained
using tr1::has_nothrow_copy; // retained
using tr1::has_nothrow_copy_constructor;
using tr1::has_nothrow_default_constructor;
using tr1::has_trivial_assign;
using tr1::has_trivial_constructor; // retained
using tr1::has_trivial_copy; // retained
using tr1::has_trivial_copy_constructor;
using tr1::has_trivial_default_constructor;
using tr1::has_trivial_destructor;
using tr1::has_virtual_destructor;
using tr1::integral_constant;
using tr1::is_abstract;
using tr1::is_arithmetic;
using tr1::is_array;
using tr1::is_base_of;
using tr1::is_class;
using tr1::is_compound;
using tr1::is_const;
using tr1::is_convertible;
using tr1::is_empty;
using tr1::is_enum;
using tr1::is_floating_point;
using tr1::is_function;
using tr1::is_fundamental;
using tr1::is_integral;
using tr1::is_lvalue_reference;
using tr1::is_member_function_pointer;
using tr1::is_member_object_pointer;
using tr1::is_member_pointer;
using tr1::is_object;
using tr1::is_pod;
using tr1::is_pointer;
using tr1::is_polymorphic;
using tr1::is_reference;
using tr1::is_rvalue_reference;
using tr1::is_same;
using tr1::is_scalar;
using tr1::is_signed;
using tr1::is_standard_layout;
using tr1::is_trivial;
using tr1::is_union;
using tr1::is_unsigned;
using tr1::is_void;
using tr1::is_volatile;
using tr1::make_signed;
using tr1::make_unsigned;
using tr1::rank;
using tr1::remove_all_extents;
using tr1::remove_const;
using tr1::remove_cv;
using tr1::remove_extent;
using tr1::remove_pointer;
using tr1::remove_reference;
using tr1::_Remove_rvalue_reference;
using tr1::remove_volatile;
using tr1::true_type;
#endif /* _HAS_TR1_IMPORTS */
#if _HAS_CPP0X
template<class _Ty>
struct _Arithmetic_traits;
template<>
struct _Arithmetic_traits<bool>
{ // specialization for bool
static const int _Rank = 1;
};
template<>
struct _Arithmetic_traits<char>
{ // specialization for char
static const int _Rank = _Arithmetic_traits<bool>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<signed char>
{ // specialization for signed char
static const int _Rank = _Arithmetic_traits<char>::_Rank;
};
template<>
struct _Arithmetic_traits<unsigned char>
{ // specialization for unsigned char
static const int _Rank = _Arithmetic_traits<char>::_Rank;
};
template<>
struct _Arithmetic_traits<short>
{ // specialization for short
static const int _Rank = _Arithmetic_traits<char>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<unsigned short>
{ // specialization for unsigned short
static const int _Rank = _Arithmetic_traits<short>::_Rank;
};
template<>
struct _Arithmetic_traits<int>
{ // specialization for int
static const int _Rank = _Arithmetic_traits<short>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<unsigned int>
{ // specialization for unsigned int
static const int _Rank = _Arithmetic_traits<int>::_Rank;
};
template<>
struct _Arithmetic_traits<long>
{ // specialization for long
static const int _Rank = _Arithmetic_traits<int>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<unsigned long>
{ // specialization for unsigned long
static const int _Rank = _Arithmetic_traits<long>::_Rank;
};
template<>
struct _Arithmetic_traits<long long>
{ // specialization for long long
static const int _Rank = _Arithmetic_traits<long>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<unsigned long long>
{ // specialization for unsigned long long
static const int _Rank = _Arithmetic_traits<long long>::_Rank;
};
template<>
struct _Arithmetic_traits<float>
{
static const int _Rank = _Arithmetic_traits<long long>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<double>
{
static const int _Rank = _Arithmetic_traits<float>::_Rank + 1;
};
template<>
struct _Arithmetic_traits<long double>
{
static const int _Rank = _Arithmetic_traits<double>::_Rank + 1;
};
template<bool _Unsigned> struct _Pickinteger
{ // type is signed
typedef int _Type;
};
template<>
struct _Pickinteger<true>
{ // type is unsigned
typedef unsigned int _Type;
};
template<class _Ty,
bool _Small>
struct _Promote_to_int;
template<class _Ty>
struct _Promote_to_int<_Ty, true>
{ // _Ty is smaller than an int
typedef int _Type;
};
template<class _Ty>
struct _Promote_to_int<_Ty, false>
{ // _Ty is the same size as an int
typedef typename _Pickinteger<tr1::is_unsigned<_Ty>::value>::_Type _Type;
};
template<class _Ty,
bool _Small>
struct _Maybepromote;
template<class _Ty>
struct _Maybepromote<_Ty, false>
{ // _Ty ranks at least as high as int
typedef _Ty _Type;
};
template<class _Ty>
struct _Maybepromote<_Ty, true>
{ // _Ty is no larger than an int
typedef typename _Promote_to_int<_Ty, sizeof(_Ty) < sizeof(int)>::_Type
_Type;
};
template<class _Ty>
struct _Ipromo
{ // arithmetic promotions
static const bool _Lessthan =
_Arithmetic_traits<_Ty>::_Rank < _Arithmetic_traits<int>::_Rank;
typedef typename _Maybepromote<_Ty, _Lessthan>::_Type _Type;
};
template<class _Ty0,
class _Ty1,
bool _Second>
struct _Common_typeX
{ // _Second is true; pick second type
typedef _Ty1 _Type;
};
template<class _Ty0,
class _Ty1>
struct _Common_typeX<_Ty0, _Ty1, false>
{ // _Second is false; pick first type
typedef _Ty0 _Type;
};
template<class _Ty0,
class _Ty1,
bool _Uns0,
bool _Uns1>
struct _Common_typeY
{ // second type not unsigned, pick first if unsigned or both signed
typedef _Ty0 _Type;
};
template<class _Ty0,
class _Ty1>
struct _Common_typeY<_Ty0, _Ty1, false, true>
{ // first type is signed, second type is unsigned; pick second type
typedef _Ty1 _Type;
};
template<class _Ty0,
class _Ty1,
int _Rank0,
int _Rank1>
struct _Common_type
{ // different ranks; pick higher ranking type
typedef typename _Common_typeX<_Ty0, _Ty1, _Rank0 < _Rank1>::_Type _Type;
};
template<class _Ty0,
class _Ty1,
int _Rank>
struct _Common_type<_Ty0, _Ty1, _Rank, _Rank>
{ // same rank; if one is unsigned, pick it
typedef typename _Common_typeY<_Ty0, _Ty1,
tr1::is_unsigned<_Ty0>::value,
tr1::is_unsigned<_Ty1>::value>::_Type _Type;
};
template<class _Ty0,
class _Ty1>
struct common_type
{ // determine common type of arithmetic types _Ty0 and _Ty1
typedef typename _Ipromo<_Ty0>::_Type _PromoTy0;
typedef typename _Ipromo<_Ty1>::_Type _PromoTy1;
typedef typename _Common_type<_PromoTy0, _PromoTy1,
_Arithmetic_traits<_PromoTy0>::_Rank,
_Arithmetic_traits<_PromoTy1>::_Rank>::_Type type;
};
#endif /* _HAS_CPP0X */
_STD_END
#pragma warning(pop)
#pragma pack(pop)
#endif /* RC_INVOKED */
#endif /* _TYPE_TRAITS_ */
/*
* Copyright (c) 1992-2009 by P.J. Plauger. ALL RIGHTS RESERVED.
* Consult your license regarding permissions and restrictions.
V5.20:0009 */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -