Message ID | 20230322001142.13422-2-kmatsui@cs.washington.edu |
---|---|
State | New |
Headers | show |
Series | [1/2] c++: implement __is_const built-in trait | expand |
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 > >
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>