type_traits (_DEFINE_SPEC*): Simplify.
2008-08-10 Paolo Carlini <paolo.carlini@oracle.com> * include/tr1_impl/type_traits (_DEFINE_SPEC*): Simplify. (_DEFINE_SPEC_BODY): Remove. (__is_void_helper, __is_integral_helper, __is_floating_point_helper, __is_member_object_pointer_helper, __is_member_function_pointer_helper, __remove_pointer_helper): Add. (is_void, is_integral, is_floating_point, is_member_object_pointer, is_member_function_pointer, remove_pointer): Use the latter. * include/tr1/type_traits (_DEFINE_SPEC): Simplify. (_DEFINE_SPEC_HELPER): Remove. (__is_signed_helper, __is_unsigned_helper): Add. (is_signed, is_unsigned): Use the latter. From-SVN: r138925
This commit is contained in:
parent
d47c3b4eb1
commit
77d4510875
@ -1,3 +1,17 @@
|
||||
2008-08-10 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
* include/tr1_impl/type_traits (_DEFINE_SPEC*): Simplify.
|
||||
(_DEFINE_SPEC_BODY): Remove.
|
||||
(__is_void_helper, __is_integral_helper, __is_floating_point_helper,
|
||||
__is_member_object_pointer_helper, __is_member_function_pointer_helper,
|
||||
__remove_pointer_helper): Add.
|
||||
(is_void, is_integral, is_floating_point, is_member_object_pointer,
|
||||
is_member_function_pointer, remove_pointer): Use the latter.
|
||||
* include/tr1/type_traits (_DEFINE_SPEC): Simplify.
|
||||
(_DEFINE_SPEC_HELPER): Remove.
|
||||
(__is_signed_helper, __is_unsigned_helper): Add.
|
||||
(is_signed, is_unsigned): Use the latter.
|
||||
|
||||
2008-08-09 Paolo Carlini <paolo.carlini@oracle.com>
|
||||
|
||||
Revert fix for libstdc++/35637, thanks to other/36901.
|
||||
|
@ -1,6 +1,6 @@
|
||||
// TR1 type_traits -*- C++ -*-
|
||||
|
||||
// Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc.
|
||||
// Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
|
||||
//
|
||||
// This file is part of the GNU ISO C++ Library. This library is free
|
||||
// software; you can redistribute it and/or modify it under the
|
||||
@ -60,17 +60,11 @@ namespace std
|
||||
{
|
||||
namespace tr1
|
||||
{
|
||||
#define _DEFINE_SPEC_HELPER(_Spec) \
|
||||
template<> \
|
||||
struct _Spec \
|
||||
#define _DEFINE_SPEC(_Trait, _Type) \
|
||||
template<> \
|
||||
struct _Trait<_Type> \
|
||||
: public true_type { };
|
||||
|
||||
#define _DEFINE_SPEC(_Trait, _Type) \
|
||||
_DEFINE_SPEC_HELPER(_Trait<_Type>) \
|
||||
_DEFINE_SPEC_HELPER(_Trait<_Type const>) \
|
||||
_DEFINE_SPEC_HELPER(_Trait<_Type volatile>) \
|
||||
_DEFINE_SPEC_HELPER(_Trait<_Type const volatile>)
|
||||
|
||||
template<typename>
|
||||
struct is_reference
|
||||
: public false_type { };
|
||||
@ -120,22 +114,34 @@ namespace tr1
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_signed
|
||||
struct __is_signed_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(is_signed, signed char)
|
||||
_DEFINE_SPEC(is_signed, short)
|
||||
_DEFINE_SPEC(is_signed, int)
|
||||
_DEFINE_SPEC(is_signed, long)
|
||||
_DEFINE_SPEC(is_signed, long long)
|
||||
_DEFINE_SPEC(__is_signed_helper, signed char)
|
||||
_DEFINE_SPEC(__is_signed_helper, short)
|
||||
_DEFINE_SPEC(__is_signed_helper, int)
|
||||
_DEFINE_SPEC(__is_signed_helper, long)
|
||||
_DEFINE_SPEC(__is_signed_helper, long long)
|
||||
|
||||
template<typename _Tp>
|
||||
struct is_signed
|
||||
: public integral_constant<bool, (__is_signed_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_unsigned
|
||||
struct __is_unsigned_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(is_unsigned, unsigned char)
|
||||
_DEFINE_SPEC(is_unsigned, unsigned short)
|
||||
_DEFINE_SPEC(is_unsigned, unsigned int)
|
||||
_DEFINE_SPEC(is_unsigned, unsigned long)
|
||||
_DEFINE_SPEC(is_unsigned, unsigned long long)
|
||||
_DEFINE_SPEC(__is_unsigned_helper, unsigned char)
|
||||
_DEFINE_SPEC(__is_unsigned_helper, unsigned short)
|
||||
_DEFINE_SPEC(__is_unsigned_helper, unsigned int)
|
||||
_DEFINE_SPEC(__is_unsigned_helper, unsigned long)
|
||||
_DEFINE_SPEC(__is_unsigned_helper, unsigned long long)
|
||||
|
||||
template<typename _Tp>
|
||||
struct is_unsigned
|
||||
: public integral_constant<bool, (__is_unsigned_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
template<typename _Base, typename _Derived>
|
||||
struct __is_base_of_helper
|
||||
@ -241,7 +247,6 @@ namespace tr1
|
||||
};
|
||||
};
|
||||
|
||||
#undef _DEFINE_SPEC_HELPER
|
||||
#undef _DEFINE_SPEC
|
||||
}
|
||||
}
|
||||
|
@ -43,30 +43,20 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
typedef struct { char __arr[2]; } __two;
|
||||
};
|
||||
|
||||
#define _DEFINE_SPEC_BODY(_Value) \
|
||||
#define _DEFINE_SPEC_0_HELPER \
|
||||
template<>
|
||||
|
||||
#define _DEFINE_SPEC_1_HELPER \
|
||||
template<typename _Tp>
|
||||
|
||||
#define _DEFINE_SPEC_2_HELPER \
|
||||
template<typename _Tp, typename _Cp>
|
||||
|
||||
#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \
|
||||
_DEFINE_SPEC_##_Order##_HELPER \
|
||||
struct _Trait<_Type> \
|
||||
: public integral_constant<bool, _Value> { };
|
||||
|
||||
#define _DEFINE_SPEC_0_HELPER(_Spec, _Value) \
|
||||
template<> \
|
||||
struct _Spec \
|
||||
_DEFINE_SPEC_BODY(_Value)
|
||||
|
||||
#define _DEFINE_SPEC_1_HELPER(_Spec, _Value) \
|
||||
template<typename _Tp> \
|
||||
struct _Spec \
|
||||
_DEFINE_SPEC_BODY(_Value)
|
||||
|
||||
#define _DEFINE_SPEC_2_HELPER(_Spec, _Value) \
|
||||
template<typename _Tp, typename _Cp> \
|
||||
struct _Spec \
|
||||
_DEFINE_SPEC_BODY(_Value)
|
||||
|
||||
#define _DEFINE_SPEC(_Order, _Trait, _Type, _Value) \
|
||||
_DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type>, _Value) \
|
||||
_DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type const>, _Value) \
|
||||
_DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type volatile>, _Value) \
|
||||
_DEFINE_SPEC_##_Order##_HELPER(_Trait<_Type const volatile>, _Value)
|
||||
|
||||
/// helper classes [4.3].
|
||||
template<typename _Tp, _Tp __v>
|
||||
struct integral_constant
|
||||
@ -79,49 +69,70 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
/// typedef for true_type
|
||||
typedef integral_constant<bool, true> true_type;
|
||||
|
||||
/// typedef for 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;
|
||||
|
||||
/// primary type categories [4.5.1].
|
||||
template<typename>
|
||||
struct is_void
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(0, is_void, void, true)
|
||||
struct remove_cv;
|
||||
|
||||
/// is_integral
|
||||
template<typename>
|
||||
struct is_integral
|
||||
struct __is_void_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(0, is_integral, bool, true)
|
||||
_DEFINE_SPEC(0, is_integral, char, true)
|
||||
_DEFINE_SPEC(0, is_integral, signed char, true)
|
||||
_DEFINE_SPEC(0, is_integral, unsigned char, true)
|
||||
_DEFINE_SPEC(0, __is_void_helper, void, true)
|
||||
|
||||
/// primary type categories [4.5.1].
|
||||
template<typename _Tp>
|
||||
struct is_void
|
||||
: public integral_constant<bool, (__is_void_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct __is_integral_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(0, __is_integral_helper, bool, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, char, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, signed char, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, unsigned char, true)
|
||||
#ifdef _GLIBCXX_USE_WCHAR_T
|
||||
_DEFINE_SPEC(0, is_integral, wchar_t, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, wchar_t, true)
|
||||
#endif
|
||||
#ifdef _GLIBCXX_INCLUDE_AS_CXX0X
|
||||
_DEFINE_SPEC(0, is_integral, char16_t, true)
|
||||
_DEFINE_SPEC(0, is_integral, char32_t, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, char16_t, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, char32_t, true)
|
||||
#endif
|
||||
_DEFINE_SPEC(0, is_integral, short, true)
|
||||
_DEFINE_SPEC(0, is_integral, unsigned short, true)
|
||||
_DEFINE_SPEC(0, is_integral, int, true)
|
||||
_DEFINE_SPEC(0, is_integral, unsigned int, true)
|
||||
_DEFINE_SPEC(0, is_integral, long, true)
|
||||
_DEFINE_SPEC(0, is_integral, unsigned long, true)
|
||||
_DEFINE_SPEC(0, is_integral, long long, true)
|
||||
_DEFINE_SPEC(0, is_integral, unsigned long long, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, short, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, unsigned short, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, int, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, unsigned int, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, long, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, unsigned long, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, long long, true)
|
||||
_DEFINE_SPEC(0, __is_integral_helper, unsigned long long, true)
|
||||
|
||||
/// is_integral
|
||||
template<typename _Tp>
|
||||
struct is_integral
|
||||
: public integral_constant<bool, (__is_integral_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct __is_floating_point_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(0, __is_floating_point_helper, float, true)
|
||||
_DEFINE_SPEC(0, __is_floating_point_helper, double, true)
|
||||
_DEFINE_SPEC(0, __is_floating_point_helper, long double, true)
|
||||
|
||||
/// is_floating_point
|
||||
template<typename>
|
||||
template<typename _Tp>
|
||||
struct is_floating_point
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(0, is_floating_point, float, true)
|
||||
_DEFINE_SPEC(0, is_floating_point, double, true)
|
||||
_DEFINE_SPEC(0, is_floating_point, long double, true)
|
||||
: public integral_constant<bool, (__is_floating_point_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
/// is_array
|
||||
template<typename>
|
||||
@ -136,11 +147,17 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
struct is_array<_Tp[]>
|
||||
: public true_type { };
|
||||
|
||||
/// is_pointer
|
||||
template<typename>
|
||||
struct is_pointer
|
||||
struct __is_pointer_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(1, is_pointer, _Tp*, true)
|
||||
_DEFINE_SPEC(1, __is_pointer_helper, _Tp*, true)
|
||||
|
||||
/// is_pointer
|
||||
template<typename _Tp>
|
||||
struct is_pointer
|
||||
: public integral_constant<bool, (__is_pointer_helper<typename
|
||||
remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
/// is_reference
|
||||
template<typename _Tp>
|
||||
@ -150,20 +167,32 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
template<typename _Tp>
|
||||
struct is_function;
|
||||
|
||||
/// is_member_object_pointer
|
||||
template<typename>
|
||||
struct is_member_object_pointer
|
||||
struct __is_member_object_pointer_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(2, is_member_object_pointer, _Tp _Cp::*,
|
||||
_DEFINE_SPEC(2, __is_member_object_pointer_helper, _Tp _Cp::*,
|
||||
!is_function<_Tp>::value)
|
||||
|
||||
/// is_member_function_pointer
|
||||
/// is_member_object_pointer
|
||||
template<typename _Tp>
|
||||
struct is_member_object_pointer
|
||||
: public integral_constant<bool, (__is_member_object_pointer_helper<
|
||||
typename remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
template<typename>
|
||||
struct is_member_function_pointer
|
||||
struct __is_member_function_pointer_helper
|
||||
: public false_type { };
|
||||
_DEFINE_SPEC(2, is_member_function_pointer, _Tp _Cp::*,
|
||||
_DEFINE_SPEC(2, __is_member_function_pointer_helper, _Tp _Cp::*,
|
||||
is_function<_Tp>::value)
|
||||
|
||||
/// is_member_function_pointer
|
||||
template<typename _Tp>
|
||||
struct is_member_function_pointer
|
||||
: public integral_constant<bool, (__is_member_function_pointer_helper<
|
||||
typename remove_cv<_Tp>::type>::value)>
|
||||
{ };
|
||||
|
||||
/// is_enum
|
||||
template<typename _Tp>
|
||||
struct is_enum
|
||||
@ -182,9 +211,6 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
: public integral_constant<bool, __is_class(_Tp)>
|
||||
{ };
|
||||
|
||||
template<typename _Tp>
|
||||
struct remove_cv;
|
||||
|
||||
template<typename>
|
||||
struct __is_function_helper
|
||||
: public false_type { };
|
||||
@ -412,18 +438,21 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
{ typedef typename remove_all_extents<_Tp>::type type; };
|
||||
|
||||
/// pointer modifications [4.7.4].
|
||||
#undef _DEFINE_SPEC_BODY
|
||||
#define _DEFINE_SPEC_BODY(_Value) \
|
||||
template<typename _Tp, typename>
|
||||
struct __remove_pointer_helper
|
||||
{ typedef _Tp type; };
|
||||
|
||||
template<typename _Tp, typename _Up>
|
||||
struct __remove_pointer_helper<_Tp, _Up*>
|
||||
{ typedef _Up type; };
|
||||
|
||||
/// remove_pointer
|
||||
template<typename _Tp>
|
||||
struct remove_pointer
|
||||
{ typedef _Tp type; };
|
||||
_DEFINE_SPEC(1, remove_pointer, _Tp*, false)
|
||||
: public __remove_pointer_helper<_Tp, typename remove_cv<_Tp>::type>
|
||||
{ };
|
||||
|
||||
/// remove_reference
|
||||
template<typename _Tp>
|
||||
template<typename>
|
||||
struct remove_reference;
|
||||
|
||||
/// add_pointer
|
||||
@ -435,7 +464,6 @@ _GLIBCXX_BEGIN_NAMESPACE_TR1
|
||||
#undef _DEFINE_SPEC_1_HELPER
|
||||
#undef _DEFINE_SPEC_2_HELPER
|
||||
#undef _DEFINE_SPEC
|
||||
#undef _DEFINE_SPEC_BODY
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_TR1
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user