From c01f9216b73597b7dc03d9387ac7e21a5089f801 Mon Sep 17 00:00:00 2001 From: Jonathan Wakely Date: Thu, 19 Jul 2018 20:12:37 +0100 Subject: [PATCH] Simplify the base characteristics for some type traits * include/std/type_traits (__is_member_object_pointer_helper): Use __not_>::type instead of integral_constant. (__is_member_function_pointer_helper): Likewise for is_function<_Tp>::type. (is_compund): Likewise for __not_>::type. (__do_is_nt_destructible_impl): Use __bool_constant and reindent. (is_trivially_constructible): Remove redundant use of is_constructible. (__is_trivially_copy_assignable_impl): Remove redundant use of is_copy_assignable. (__is_trivially_move_assignable_impl): Remove redundant use of is_move_assignable. (is_trivially_destructible): Use __bool_constant. * testsuite/20_util/is_trivially_assignable/value.cc: Add some more tests for scalar types. From-SVN: r262889 --- libstdc++-v3/ChangeLog | 18 ++++ libstdc++-v3/include/std/type_traits | 25 ++--- .../20_util/is_trivially_assignable/value.cc | 108 +++++++++++++-------- 3 files changed, 93 insertions(+), 58 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 00bcf2d..ea7db96 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,21 @@ +2018-07-19 Jonathan Wakely + + * include/std/type_traits (__is_member_object_pointer_helper): Use + __not_>::type instead of integral_constant. + (__is_member_function_pointer_helper): Likewise for + is_function<_Tp>::type. + (is_compund): Likewise for __not_>::type. + (__do_is_nt_destructible_impl): Use __bool_constant and reindent. + (is_trivially_constructible): Remove redundant use of + is_constructible. + (__is_trivially_copy_assignable_impl): Remove redundant use of + is_copy_assignable. + (__is_trivially_move_assignable_impl): Remove redundant use of + is_move_assignable. + (is_trivially_destructible): Use __bool_constant. + * testsuite/20_util/is_trivially_assignable/value.cc: Add some more + tests for scalar types. + 2018-07-19 Glen Joseph Fernandes * include/bits/stl_algobase.h (__copy_move_a): Used diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 4df82bf..aaa554c 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_member_object_pointer_helper<_Tp _Cp::*> - : public integral_constant::value> { }; + : public __not_>::type { }; /// is_member_object_pointer template @@ -411,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_member_function_pointer_helper<_Tp _Cp::*> - : public integral_constant::value> { }; + : public is_function<_Tp>::type { }; /// is_member_function_pointer template @@ -603,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_compound template struct is_compound - : public integral_constant::value> { }; + : public __not_>::type { }; template struct __is_member_pointer_helper @@ -826,8 +826,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION struct __do_is_nt_destructible_impl { template - static integral_constant().~_Tp())> - __test(int); + static __bool_constant().~_Tp())> + __test(int); template static false_type __test(...); @@ -1136,8 +1136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_constructible template struct is_trivially_constructible - : public __and_, __bool_constant< - __is_trivially_constructible(_Tp, _Args...)>>::type + : public __bool_constant<__is_trivially_constructible(_Tp, _Args...)> { }; /// is_trivially_default_constructible @@ -1235,9 +1234,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_trivially_copy_assignable_impl<_Tp, true> - : public __and_, - integral_constant> + : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)> { }; template @@ -1256,9 +1253,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION template struct __is_trivially_move_assignable_impl<_Tp, true> - : public __and_, - integral_constant> + : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)> { }; template @@ -1269,8 +1264,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION /// is_trivially_destructible template struct is_trivially_destructible - : public __and_, integral_constant> + : public __and_, + __bool_constant<__has_trivial_destructor(_Tp)>> { }; diff --git a/libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc b/libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc index 1015d07..f3d73cb 100644 --- a/libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc +++ b/libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc @@ -44,91 +44,113 @@ void test01() using std::is_trivially_assignable; using namespace __gnu_test; - static_assert(test_property(false), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(true), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(false), ""); + static_assert(test_property(true), ""); + static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(false), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(false), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(false), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(true), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); - static_assert(test_property(false), ""); } -- 2.7.4