public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH] libstdc++: Consistently use ::type when deriving from __and/or/not_
@ 2022-09-02 16:38 Patrick Palka
  2022-09-02 18:10 ` Jonathan Wakely
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Palka @ 2022-09-02 16:38 UTC (permalink / raw)
  To: gcc-patches; +Cc: libstdc++, Patrick Palka

Now that these internal type traits are again class templates, it's
better to derive from the trait's ::type (which is either false_type or
true_type) instead of from the trait itself, for sake of a shallower
inheritance chain.  We usually do this but not always; this patch makes
us consistently do so.

Tested on x86_64-pc-lnux-gnu, does this look OK for trunk?  (Compile
time for join.cc decreases by about 0.5% with this, avg of 10 runs.)

libstdc++-v3/ChangeLog:

	* include/std/tuple (tuple::_UseOtherCtor): Do ::type when
	deriving from __and_, __or_ or __not_.
	* include/std/type_traits (negation): Likewise.
	(is_unsigned): Likewise.
	(__is_implicitly_default_constructible): Likewise.
	(is_trivially_destructible): Likewise.
	(__is_nt_invocable_impl): Likewise.
---
 libstdc++-v3/include/std/tuple       |  2 +-
 libstdc++-v3/include/std/type_traits | 10 +++++-----
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
index ddd7c226d80..26e248431ec 100644
--- a/libstdc++-v3/include/std/tuple
+++ b/libstdc++-v3/include/std/tuple
@@ -826,7 +826,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       // then TUPLE should match tuple(UTypes&&...) instead.
       template<typename _Tuple, typename _Tp, typename _Up>
 	struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
-	: __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
+	: __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>::type
 	{ };
       // If TUPLE and *this each have a single element of the same type,
       // then TUPLE should match a copy/move constructor instead.
diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
index be9f2955539..c0bb1cf64e3 100644
--- a/libstdc++-v3/include/std/type_traits
+++ b/libstdc++-v3/include/std/type_traits
@@ -235,7 +235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
 
   template<typename _Pp>
     struct negation
-    : __not_<_Pp>
+    : __not_<_Pp>::type
     { };
 
   /** @ingroup variable_templates
@@ -845,7 +845,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   /// is_unsigned
   template<typename _Tp>
     struct is_unsigned
-    : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
+    : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
     { };
 
   /// @cond undocumented
@@ -1222,7 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template <typename _Tp>
     struct __is_implicitly_default_constructible
     : public __and_<__is_constructible_impl<_Tp>,
-		    __is_implicitly_default_constructible_safe<_Tp>>
+		    __is_implicitly_default_constructible_safe<_Tp>>::type
     { };
 
   /// is_trivially_copy_constructible
@@ -1282,7 +1282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct is_trivially_destructible
     : public __and_<__is_destructible_safe<_Tp>,
-		    __bool_constant<__has_trivial_destructor(_Tp)>>
+		    __bool_constant<__has_trivial_destructor(_Tp)>>::type
     {
       static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
 	"template argument must be a complete class or an unbounded array");
@@ -2975,7 +2975,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     struct __is_nt_invocable_impl<_Result, _Ret,
 				  __void_t<typename _Result::type>>
     : __or_<is_void<_Ret>,
-	    __is_nothrow_convertible<typename _Result::type, _Ret>>
+	    __is_nothrow_convertible<typename _Result::type, _Ret>>::type
     { };
   /// @endcond
 
-- 
2.37.2.490.g6c8e4ee870


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] libstdc++: Consistently use ::type when deriving from __and/or/not_
  2022-09-02 16:38 [PATCH] libstdc++: Consistently use ::type when deriving from __and/or/not_ Patrick Palka
@ 2022-09-02 18:10 ` Jonathan Wakely
  0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Wakely @ 2022-09-02 18:10 UTC (permalink / raw)
  To: Patrick Palka; +Cc: gcc-patches, libstdc++

On Fri, 2 Sept 2022 at 17:39, Patrick Palka via Libstdc++
<libstdc++@gcc.gnu.org> wrote:
>
> Now that these internal type traits are again class templates, it's
> better to derive from the trait's ::type (which is either false_type or
> true_type) instead of from the trait itself, for sake of a shallower
> inheritance chain.  We usually do this but not always; this patch makes
> us consistently do so.
>
> Tested on x86_64-pc-lnux-gnu, does this look OK for trunk?  (Compile
> time for join.cc decreases by about 0.5% with this, avg of 10 runs.)

OK, thanks.


>
> libstdc++-v3/ChangeLog:
>
>         * include/std/tuple (tuple::_UseOtherCtor): Do ::type when
>         deriving from __and_, __or_ or __not_.
>         * include/std/type_traits (negation): Likewise.
>         (is_unsigned): Likewise.
>         (__is_implicitly_default_constructible): Likewise.
>         (is_trivially_destructible): Likewise.
>         (__is_nt_invocable_impl): Likewise.
> ---
>  libstdc++-v3/include/std/tuple       |  2 +-
>  libstdc++-v3/include/std/type_traits | 10 +++++-----
>  2 files changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/libstdc++-v3/include/std/tuple b/libstdc++-v3/include/std/tuple
> index ddd7c226d80..26e248431ec 100644
> --- a/libstdc++-v3/include/std/tuple
> +++ b/libstdc++-v3/include/std/tuple
> @@ -826,7 +826,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>        // then TUPLE should match tuple(UTypes&&...) instead.
>        template<typename _Tuple, typename _Tp, typename _Up>
>         struct _UseOtherCtor<_Tuple, tuple<_Tp>, tuple<_Up>>
> -       : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>
> +       : __or_<is_convertible<_Tuple, _Tp>, is_constructible<_Tp, _Tuple>>::type
>         { };
>        // If TUPLE and *this each have a single element of the same type,
>        // then TUPLE should match a copy/move constructor instead.
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index be9f2955539..c0bb1cf64e3 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -235,7 +235,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>
>    template<typename _Pp>
>      struct negation
> -    : __not_<_Pp>
> +    : __not_<_Pp>::type
>      { };
>
>    /** @ingroup variable_templates
> @@ -845,7 +845,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    /// is_unsigned
>    template<typename _Tp>
>      struct is_unsigned
> -    : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>
> +    : public __and_<is_arithmetic<_Tp>, __not_<is_signed<_Tp>>>::type
>      { };
>
>    /// @cond undocumented
> @@ -1222,7 +1222,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    template <typename _Tp>
>      struct __is_implicitly_default_constructible
>      : public __and_<__is_constructible_impl<_Tp>,
> -                   __is_implicitly_default_constructible_safe<_Tp>>
> +                   __is_implicitly_default_constructible_safe<_Tp>>::type
>      { };
>
>    /// is_trivially_copy_constructible
> @@ -1282,7 +1282,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>    template<typename _Tp>
>      struct is_trivially_destructible
>      : public __and_<__is_destructible_safe<_Tp>,
> -                   __bool_constant<__has_trivial_destructor(_Tp)>>
> +                   __bool_constant<__has_trivial_destructor(_Tp)>>::type
>      {
>        static_assert(std::__is_complete_or_unbounded(__type_identity<_Tp>{}),
>         "template argument must be a complete class or an unbounded array");
> @@ -2975,7 +2975,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      struct __is_nt_invocable_impl<_Result, _Ret,
>                                   __void_t<typename _Result::type>>
>      : __or_<is_void<_Ret>,
> -           __is_nothrow_convertible<typename _Result::type, _Ret>>
> +           __is_nothrow_convertible<typename _Result::type, _Ret>>::type
>      { };
>    /// @endcond
>
> --
> 2.37.2.490.g6c8e4ee870
>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-09-02 18:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-02 16:38 [PATCH] libstdc++: Consistently use ::type when deriving from __and/or/not_ Patrick Palka
2022-09-02 18:10 ` Jonathan Wakely

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).