Re: [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
On Fri, 9 Feb 2024 at 16:02, Patrick Palka wrote: > On Thu, 8 Feb 2024, Ken Matsui wrote: > > > Since is_same has a fallback native implementation, and > > _GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which > > implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME > > definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead. > > > > libstdc++-v3/ChangeLog: > > > > * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME): > > Removed. > > * include/std/type_traits (is_same): Use > > _GLIBCXX_USE_BUILTIN_TRAIT instead of > > _GLIBCXX_HAVE_BUILTIN_IS_SAME. > > (is_same_v): Likewise. > > LGTM > Me too, OK for trunk, thanks. +Reviewed-by: Jonathan Wakely > > > > > Signed-off-by: Ken Matsui > > --- > > libstdc++-v3/include/bits/c++config | 4 > > libstdc++-v3/include/std/type_traits | 9 + > > 2 files changed, 5 insertions(+), 8 deletions(-) > > > > diff --git a/libstdc++-v3/include/bits/c++config > b/libstdc++-v3/include/bits/c++config > > index ad07ce92d5f..b57e3f338e9 100644 > > --- a/libstdc++-v3/include/bits/c++config > > +++ b/libstdc++-v3/include/bits/c++config > > @@ -845,10 +845,6 @@ namespace __gnu_cxx > > # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 > > #endif > > > > -#if _GLIBCXX_HAS_BUILTIN(__is_same) > > -# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 > > -#endif > > - > > #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) > > # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 > > #endif > > diff --git a/libstdc++-v3/include/std/type_traits > b/libstdc++-v3/include/std/type_traits > > index a9bb2806ca9..21402fd8c13 100644 > > --- a/libstdc++-v3/include/std/type_traits > > +++ b/libstdc++-v3/include/std/type_traits > > @@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > >// Type relations. > > > >/// is_same > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) > >template > > struct is_same > > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME > > : public __bool_constant<__is_same(_Tp, _Up)> > > +{ }; > > #else > > + template > > +struct is_same > > : public false_type > > -#endif > > { }; > > > > -#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME > >template > > struct is_same<_Tp, _Tp> > > : public true_type > > @@ -3496,7 +3497,7 @@ template > > template > >inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - > 1>; > > > > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME > > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) > > template > >inline constexpr bool is_same_v = __is_same(_Tp, _Up); > > #else > > -- > > 2.43.0 > > > > > >
Re: [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
On Thu, 8 Feb 2024, Ken Matsui wrote: > Since is_same has a fallback native implementation, and > _GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which > implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME > definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead. > > libstdc++-v3/ChangeLog: > > * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME): > Removed. > * include/std/type_traits (is_same): Use > _GLIBCXX_USE_BUILTIN_TRAIT instead of > _GLIBCXX_HAVE_BUILTIN_IS_SAME. > (is_same_v): Likewise. LGTM > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/bits/c++config | 4 > libstdc++-v3/include/std/type_traits | 9 + > 2 files changed, 5 insertions(+), 8 deletions(-) > > diff --git a/libstdc++-v3/include/bits/c++config > b/libstdc++-v3/include/bits/c++config > index ad07ce92d5f..b57e3f338e9 100644 > --- a/libstdc++-v3/include/bits/c++config > +++ b/libstdc++-v3/include/bits/c++config > @@ -845,10 +845,6 @@ namespace __gnu_cxx > # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 > #endif > > -#if _GLIBCXX_HAS_BUILTIN(__is_same) > -# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 > -#endif > - > #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) > # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 > #endif > diff --git a/libstdc++-v3/include/std/type_traits > b/libstdc++-v3/include/std/type_traits > index a9bb2806ca9..21402fd8c13 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >// Type relations. > >/// is_same > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) >template > struct is_same > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME > : public __bool_constant<__is_same(_Tp, _Up)> > +{ }; > #else > + template > +struct is_same > : public false_type > -#endif > { }; > > -#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME >template > struct is_same<_Tp, _Tp> > : public true_type > @@ -3496,7 +3497,7 @@ template > template >inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - 1>; > > -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) > template >inline constexpr bool is_same_v = __is_same(_Tp, _Up); > #else > -- > 2.43.0 > >
[PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for is_same
Since is_same has a fallback native implementation, and _GLIBCXX_HAVE_BUILTIN_IS_SAME does not support toggling which implementation to use, we remove the _GLIBCXX_HAVE_BUILTIN_IS_SAME definition and use _GLIBCXX_USE_BUILTIN_TRAIT instead. libstdc++-v3/ChangeLog: * include/bits/c++config (_GLIBCXX_HAVE_BUILTIN_IS_SAME): Removed. * include/std/type_traits (is_same): Use _GLIBCXX_USE_BUILTIN_TRAIT instead of _GLIBCXX_HAVE_BUILTIN_IS_SAME. (is_same_v): Likewise. Signed-off-by: Ken Matsui --- libstdc++-v3/include/bits/c++config | 4 libstdc++-v3/include/std/type_traits | 9 + 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/libstdc++-v3/include/bits/c++config b/libstdc++-v3/include/bits/c++config index ad07ce92d5f..b57e3f338e9 100644 --- a/libstdc++-v3/include/bits/c++config +++ b/libstdc++-v3/include/bits/c++config @@ -845,10 +845,6 @@ namespace __gnu_cxx # define _GLIBCXX_HAVE_BUILTIN_IS_AGGREGATE 1 #endif -#if _GLIBCXX_HAS_BUILTIN(__is_same) -# define _GLIBCXX_HAVE_BUILTIN_IS_SAME 1 -#endif - #if _GLIBCXX_HAS_BUILTIN(__builtin_launder) # define _GLIBCXX_HAVE_BUILTIN_LAUNDER 1 #endif diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index a9bb2806ca9..21402fd8c13 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1470,16 +1470,17 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Type relations. /// is_same +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) template struct is_same -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME : public __bool_constant<__is_same(_Tp, _Up)> +{ }; #else + template +struct is_same : public false_type -#endif { }; -#ifndef _GLIBCXX_HAVE_BUILTIN_IS_SAME template struct is_same<_Tp, _Tp> : public true_type @@ -3496,7 +3497,7 @@ template template inline constexpr size_t extent_v<_Tp[], _Idx> = extent_v<_Tp, _Idx - 1>; -#ifdef _GLIBCXX_HAVE_BUILTIN_IS_SAME +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_same) template inline constexpr bool is_same_v = __is_same(_Tp, _Up); #else -- 2.43.0
Re: [PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for _Nth_type
On Wed, 10 Jan 2024 at 22:08, Patrick Palka wrote: > > Tested on x86_64-pc-linux-gnu, does this look OK for trunk? OK (thanks, this was on my TODO list). > -- >8 -- > > Since _Nth_type has a fallback native implementation, use > _GLIBCXX_USE_BUILTIN_TRAIT when deciding whether __type_pack_element > is available so that we can easily toggle which implementation > to use.
[PATCH] libstdc++: Use _GLIBCXX_USE_BUILTIN_TRAIT for _Nth_type
Tested on x86_64-pc-linux-gnu, does this look OK for trunk? -- >8 -- Since _Nth_type has a fallback native implementation, use _GLIBCXX_USE_BUILTIN_TRAIT when deciding whether __type_pack_element is available so that we can easily toggle which implementation to use. libstdc++-v3/ChangeLog: * include/bits/utility.h (_Nth_type): Use _GLIBCXX_USE_BUILTIN_TRAIT instead of __has_builtin. --- libstdc++-v3/include/bits/utility.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libstdc++-v3/include/bits/utility.h b/libstdc++-v3/include/bits/utility.h index 45d7241da9f..d8a5fb960fe 100644 --- a/libstdc++-v3/include/bits/utility.h +++ b/libstdc++-v3/include/bits/utility.h @@ -225,7 +225,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #endif // C++17 -#if __has_builtin(__type_pack_element) +#if _GLIBCXX_USE_BUILTIN_TRAIT(__type_pack_element) template struct _Nth_type { using type = __type_pack_element<_Np, _Types...>; }; -- 2.43.0.283.ga54a84b333
Re: [PATCH] libstdc++ Use _GLIBCXX_USE_BUILTIN_TRAIT
On Mon, 11 Sep 2023, Ken Matsui via Gcc-patches wrote: > This patch uses _GLIBCXX_USE_BUILTIN_TRAIT macro instead of __has_builtin in > the type_traits header for traits that have a corresponding fallback > non-built-in implementation. This macro supports to toggle the use of built-in > traits in the type_traits header through _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS > macro, without needing to modify the source code. > > libstdc++-v3/ChangeLog: > > * include/std/type_traits: Use _GLIBCXX_USE_BUILTIN_TRAIT. LGTM > > Signed-off-by: Ken Matsui > --- > libstdc++-v3/include/std/type_traits | 10 +- > 1 file changed, 5 insertions(+), 5 deletions(-) > > diff --git a/libstdc++-v3/include/std/type_traits > b/libstdc++-v3/include/std/type_traits > index 677cd934b94..221c809dd6d 100644 > --- a/libstdc++-v3/include/std/type_traits > +++ b/libstdc++-v3/include/std/type_traits > @@ -1430,7 +1430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > : public __bool_constant<__is_base_of(_Base, _Derived)> > { }; > > -#if __has_builtin(__is_convertible) > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible) >template > struct is_convertible > : public __bool_constant<__is_convertible(_From, _To)> > @@ -1480,7 +1480,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > > #ifdef __cpp_lib_is_nothrow_convertible // C++ >= 20 > > -#if __has_builtin(__is_nothrow_convertible) > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_convertible) >/// is_nothrow_convertible_v >template > inline constexpr bool is_nothrow_convertible_v > @@ -1555,7 +1555,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION > { using type = _Tp; }; > >/// remove_cv > -#if __has_builtin(__remove_cv) > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cv) >template > struct remove_cv > { using type = __remove_cv(_Tp); }; > @@ -1621,7 +1621,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION >// Reference transformations. > >/// remove_reference > -#if __has_builtin(__remove_reference) > +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_reference) >template > struct remove_reference > { using type = __remove_reference(_Tp); }; > @@ -3427,7 +3427,7 @@ template > * @{ > */ > #ifdef __cpp_lib_remove_cvref // C++ >= 20 > -# if __has_builtin(__remove_cvref) > +# if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cvref) >template > struct remove_cvref > { using type = __remove_cvref(_Tp); }; > -- > 2.42.0 > >
[PATCH] libstdc++ Use _GLIBCXX_USE_BUILTIN_TRAIT
This patch uses _GLIBCXX_USE_BUILTIN_TRAIT macro instead of __has_builtin in the type_traits header for traits that have a corresponding fallback non-built-in implementation. This macro supports to toggle the use of built-in traits in the type_traits header through _GLIBCXX_DO_NOT_USE_BUILTIN_TRAITS macro, without needing to modify the source code. libstdc++-v3/ChangeLog: * include/std/type_traits: Use _GLIBCXX_USE_BUILTIN_TRAIT. Signed-off-by: Ken Matsui --- libstdc++-v3/include/std/type_traits | 10 +- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits index 677cd934b94..221c809dd6d 100644 --- a/libstdc++-v3/include/std/type_traits +++ b/libstdc++-v3/include/std/type_traits @@ -1430,7 +1430,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION : public __bool_constant<__is_base_of(_Base, _Derived)> { }; -#if __has_builtin(__is_convertible) +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_convertible) template struct is_convertible : public __bool_constant<__is_convertible(_From, _To)> @@ -1480,7 +1480,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION #ifdef __cpp_lib_is_nothrow_convertible // C++ >= 20 -#if __has_builtin(__is_nothrow_convertible) +#if _GLIBCXX_USE_BUILTIN_TRAIT(__is_nothrow_convertible) /// is_nothrow_convertible_v template inline constexpr bool is_nothrow_convertible_v @@ -1555,7 +1555,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION { using type = _Tp; }; /// remove_cv -#if __has_builtin(__remove_cv) +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cv) template struct remove_cv { using type = __remove_cv(_Tp); }; @@ -1621,7 +1621,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION // Reference transformations. /// remove_reference -#if __has_builtin(__remove_reference) +#if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_reference) template struct remove_reference { using type = __remove_reference(_Tp); }; @@ -3427,7 +3427,7 @@ template * @{ */ #ifdef __cpp_lib_remove_cvref // C++ >= 20 -# if __has_builtin(__remove_cvref) +# if _GLIBCXX_USE_BUILTIN_TRAIT(__remove_cvref) template struct remove_cvref { using type = __remove_cvref(_Tp); }; -- 2.42.0