]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
libstdc++: Don't use std::__is_scalar in std::valarray initialization [PR115497]
authorJonathan Wakely <jwakely@redhat.com>
Wed, 19 Jun 2024 10:19:58 +0000 (11:19 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Fri, 21 Jun 2024 16:07:00 +0000 (17:07 +0100)
This removes the use of the std::__is_scalar trait from <valarray>,
where it can be replaced by __is_trivial. It's used to decide whether we
can use memset to value-initialize valarray elements, but memset is
suitable for any trivial types, because value-initializing them is
equivalent to filling them with zeros.

This is another step towards removing the class templates in
<bits/cpp_type_traits.h> that conflict with Clang built-in names.

libstdc++-v3/ChangeLog:

PR libstdc++/115497
* include/bits/valarray_array.h (__valarray_default_construct):
Use __is_trivial(_Tp). instead of __is_scalar<_Tp>.

libstdc++-v3/include/bits/valarray_array.h

index 66b74f9aaac5623f7aacf546a553d84c31f4f36a..07c49ce1057caa524c1a0d88da6bdf6a2a9e3afe 100644 (file)
@@ -80,7 +80,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
   template<typename _Tp>
     struct _Array_default_ctor<_Tp, true>
     {
-      // For fundamental types, it suffices to say 'memset()'
+      // For trivial types, it suffices to say 'memset()'
       inline static void
       _S_do_it(_Tp* __b, _Tp* __e)
       { __builtin_memset(__b, 0, (__e - __b) * sizeof(_Tp)); }
@@ -90,7 +90,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
     inline void
     __valarray_default_construct(_Tp* __b, _Tp* __e)
     {
-      _Array_default_ctor<_Tp, __is_scalar<_Tp>::__value>::_S_do_it(__b, __e);
+      _Array_default_ctor<_Tp, __is_trivial(_Tp)>::_S_do_it(__b, __e);
     }
 
   // Turn a raw-memory into an array of _Tp filled with __t