On 15/11/19 22:17 -0500, Ed Smith-Rowland via libstdc++ wrote:
Index: include/bits/stl_algobase.h
===================================================================
--- include/bits/stl_algobase.h (revision 278318)
+++ include/bits/stl_algobase.h (working copy)
@@ -107,6 +107,50 @@
    }

  /*
+   * A constexpr wrapper for __builtin_memmove.

This should say __builtin_memcpy.

+   * @param __num The number of elements of type _Tp (not bytes).
+   */
+  template<typename _Tp>
+    _GLIBCXX14_CONSTEXPR
+    inline void*
+    __memcpy(_Tp* __dst, const _Tp* __src, size_t __num)
+    {
+#ifdef __cpp_lib_is_constant_evaluated
+      if (std::is_constant_evaluated())
+       {
+         for(; __num > 0; --__num)
+           *__dst++ = *__src++;
+         return __dst;
+       }
+      else
+#endif
+       return __builtin_memcpy(__dst, __src, sizeof(_Tp) * __num);
+      return __dst;
+    }
+
+  /*
+   * A constexpr wrapper for __builtin_memmove.

And this should say __builtin_memset.

+   * @param __num The number of elements of type _Tp (not bytes).
+   */
+  template<typename _Tp>
+    _GLIBCXX14_CONSTEXPR
+    inline void*
+    __memset(_Tp* __dst, _Tp __a, size_t __num)
+    {
+#ifdef __cpp_lib_is_constant_evaluated
+      if (std::is_constant_evaluated())
+       {
+         for(; __num > 0; --__num)
+           *__dst = __a;
+         return __dst;
+       }
+      else
+#endif
+       return __builtin_memset(__dst, __a, sizeof(_Tp) * __num);
+      return __dst;
+    }

OK for trunk with those two comment fixes. Thanks.


Reply via email to