[2/2] libstdc++: use new built-in trait __is_const
Commit Message
This patch lets libstdc++ use new built-in trait __is_const.
libstdc++-v3/ChangeLog:
* include/std/type_traits (is_const): Use __is_const built-in trait.
---
libstdc++-v3/include/std/type_traits | 7 +++++++
1 file changed, 7 insertions(+)
Comments
On Tue, 21 Mar 2023, Ken Matsui wrote:
> This patch lets libstdc++ use new built-in trait __is_const.
>
> libstdc++-v3/ChangeLog:
>
> * include/std/type_traits (is_const): Use __is_const built-in trait.
We should also use it in is_const_v (likewise for the __is_array and
__is_volatile patches).
> ---
> libstdc++-v3/include/std/type_traits | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/libstdc++-v3/include/std/type_traits b/libstdc++-v3/include/std/type_traits
> index 2bd607a8b8f..e77de828501 100644
> --- a/libstdc++-v3/include/std/type_traits
> +++ b/libstdc++-v3/include/std/type_traits
> @@ -764,6 +764,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> // Type properties.
>
> /// is_const
> +#if __has_builtin(__is_const)
> + template<typename _Tp>
> + struct is_const
> + : public __bool_constant<__is_const(_Tp)>
> + { };
> +#else
> template<typename>
> struct is_const
> : public false_type { };
> @@ -771,6 +777,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> template<typename _Tp>
> struct is_const<_Tp const>
> : public true_type { };
> +#endif
>
> /// is_volatile
> template<typename>
> --
> 2.40.0
>
>
@@ -764,6 +764,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
// Type properties.
/// is_const
+#if __has_builtin(__is_const)
+ template<typename _Tp>
+ struct is_const
+ : public __bool_constant<__is_const(_Tp)>
+ { };
+#else
template<typename>
struct is_const
: public false_type { };
@@ -771,6 +777,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
template<typename _Tp>
struct is_const<_Tp const>
: public true_type { };
+#endif
/// is_volatile
template<typename>