Simplify the base characteristics for some type traits
authorJonathan Wakely <jwakely@redhat.com>
Thu, 19 Jul 2018 19:12:37 +0000 (20:12 +0100)
committerJonathan Wakely <redi@gcc.gnu.org>
Thu, 19 Jul 2018 19:12:37 +0000 (20:12 +0100)
* include/std/type_traits (__is_member_object_pointer_helper): Use
__not_<is_function<_Tp>>::type instead of integral_constant.
(__is_member_function_pointer_helper): Likewise for
is_function<_Tp>::type.
(is_compund): Likewise for __not_<is_fundamental<_Tp>>::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
libstdc++-v3/include/std/type_traits
libstdc++-v3/testsuite/20_util/is_trivially_assignable/value.cc

index 00bcf2de3c1b689820a3f35d7e90a5ef5e81cd15..ea7db96f2226e4839d45a849e68de633f8bfe318 100644 (file)
@@ -1,3 +1,21 @@
+2018-07-19  Jonathan Wakely  <jwakely@redhat.com>
+
+       * include/std/type_traits (__is_member_object_pointer_helper): Use
+       __not_<is_function<_Tp>>::type instead of integral_constant.
+       (__is_member_function_pointer_helper): Likewise for
+       is_function<_Tp>::type.
+       (is_compund): Likewise for __not_<is_fundamental<_Tp>>::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  <glenjofe@gmail.com>
 
        * include/bits/stl_algobase.h (__copy_move_a): Used
index 4df82bf6d8c292cde173e9a53fc9e2556d0a66a4..aaa554c6200079a503cedb688ef1e24c20d4d460 100644 (file)
@@ -396,7 +396,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp, typename _Cp>
     struct __is_member_object_pointer_helper<_Tp _Cp::*>
-    : public integral_constant<bool, !is_function<_Tp>::value> { };
+    : public __not_<is_function<_Tp>>::type { };
 
   /// is_member_object_pointer
   template<typename _Tp>
@@ -411,7 +411,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp, typename _Cp>
     struct __is_member_function_pointer_helper<_Tp _Cp::*>
-    : public integral_constant<bool, is_function<_Tp>::value> { };
+    : public is_function<_Tp>::type { };
 
   /// is_member_function_pointer
   template<typename _Tp>
@@ -603,7 +603,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_compound
   template<typename _Tp>
     struct is_compound
-    : public integral_constant<bool, !is_fundamental<_Tp>::value> { };
+    : public __not_<is_fundamental<_Tp>>::type { };
 
   template<typename _Tp>
     struct __is_member_pointer_helper
@@ -826,8 +826,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   struct __do_is_nt_destructible_impl
   {
     template<typename _Tp>
-      static integral_constant<bool, noexcept(declval<_Tp&>().~_Tp())>
-        __test(int);
+      static __bool_constant<noexcept(declval<_Tp&>().~_Tp())>
+      __test(int);
 
     template<typename>
       static false_type __test(...);
@@ -1136,8 +1136,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_trivially_constructible
   template<typename _Tp, typename... _Args>
     struct is_trivially_constructible
-    : public __and_<is_constructible<_Tp, _Args...>, __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<typename _Tp>
     struct __is_trivially_copy_assignable_impl<_Tp, true>
-    : public __and_<is_copy_assignable<_Tp>,
-                   integral_constant<bool,
-                       __is_trivially_assignable(_Tp&, const _Tp&)>>
+    : public __bool_constant<__is_trivially_assignable(_Tp&, const _Tp&)>
     { };
 
   template<typename _Tp>
@@ -1256,9 +1253,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Tp>
     struct __is_trivially_move_assignable_impl<_Tp, true>
-    : public __and_<is_move_assignable<_Tp>,
-                   integral_constant<bool,
-                       __is_trivially_assignable(_Tp&, _Tp&&)>>
+    : public __bool_constant<__is_trivially_assignable(_Tp&, _Tp&&)>
     { };
 
   template<typename _Tp>
@@ -1269,8 +1264,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_trivially_destructible
   template<typename _Tp>
     struct is_trivially_destructible
-    : public __and_<is_destructible<_Tp>, integral_constant<bool,
-                             __has_trivial_destructor(_Tp)>>
+    : public __and_<is_destructible<_Tp>,
+                   __bool_constant<__has_trivial_destructor(_Tp)>>
     { };
 
 
index 1015d07c31456c190f128224cb4edc50da784633..f3d73cb7e980d85e7bda6b889154ec5ecaf603e3 100644 (file)
@@ -44,91 +44,113 @@ void test01()
   using std::is_trivially_assignable;
   using namespace __gnu_test;
 
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                int, int>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                int&, int>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                int&, int&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                int&, int&&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                int&, const int&>(true), "");
+  static_assert(test_property<is_trivially_assignable,
+               int&, int*>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               int&, void*>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const int, int>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const int&, int>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const int&, const int&>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const int*&, int*>(true), "");
+  static_assert(test_property<is_trivially_assignable,
+               int*&, const int*&>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               int*&, const int&>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const int*&, void*>(false), "");
+  static_assert(test_property<is_trivially_assignable,
+               const void*&, void*>(true), "");
+  static_assert(test_property<is_trivially_assignable,
+               const void*&, int*>(true), "");
 
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                TType, TType>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                TType&, TType>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                TType&, TType&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                TType&, TType&&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                TType&, const TType&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                PODType, PODType>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                NType&, NType&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                SLType, SLType>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::Empty, assign::Empty>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::Abstract, assign::Abstract>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::Ellipsis, assign::Ellipsis>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::DelEllipsis, assign::DelEllipsis>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::Any, assign::Any>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::DelDef, assign::DelDef>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::DelCopy, assign::DelCopy>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::Nontrivial, assign::Nontrivial>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::AnyAssign, assign::AnyAssign>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::DelAnyAssign, assign::DelAnyAssign>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::DelCopyAssign, assign::DelCopyAssign>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::MO, assign::MO>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::MO, assign::MO&&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::MO, assign::MO&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                assign::MO, const assign::MO&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                CopyConsOnlyType, CopyConsOnlyType>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                CopyConsOnlyType, const CopyConsOnlyType&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveConsOnlyType, MoveConsOnlyType>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveConsOnlyType, MoveConsOnlyType&&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                HasTemplateCAssign, HasTemplateCAssign>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                HasTemplateCAssign, const HasTemplateCAssign&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                ClassType, DerivedType>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                ClassType, DerivedType&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                ClassType, DerivedType&&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                ClassType, const DerivedType&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveOnly, MoveOnly>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveOnly, MoveOnly&&>(true), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveOnly, MoveOnly&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveOnly, const MoveOnly&>(false), "");
-  static_assert(test_property<is_trivially_assignable, 
+  static_assert(test_property<is_trivially_assignable,
                MoveOnly2, MoveOnly2>(false), "");
 }