C++20 P1032 for __debug::array

Message ID 373da142-a368-9575-2a75-05b92ccb94c6@gmail.com
State New
Headers show
Series
  • C++20 P1032 for __debug::array
Related show

Commit Message

François Dumont Nov. 25, 2019, 9:34 p.m.
I plan to commit this tomorrow.

But I really wonder if we couldn't just add some __glibcxx_checks_xxx in 
std/array ?

     * include/debug/array (array<>::fill): Add C++20 constexpr.
     (array<>::swap): Likewise.

François

Comments

Jonathan Wakely Nov. 25, 2019, 10:18 p.m. | #1
On 25/11/19 22:34 +0100, François Dumont wrote:
>I plan to commit this tomorrow.


Thanks.

>But I really wonder if we couldn't just add some __glibcxx_checks_xxx 

>in std/array ?


That probably makes sense. std::array<T, N>::iterator is just T* so we
don't get debug iterators anyway.

Patch

diff --git a/libstdc++-v3/include/debug/array b/libstdc++-v3/include/debug/array
index 5566a087f9a..4e0fac8daac 100644
--- a/libstdc++-v3/include/debug/array
+++ b/libstdc++-v3/include/debug/array
@@ -80,11 +80,11 @@  namespace __debug
       // No explicit construct/copy/destroy for aggregate type.
 
       // DR 776.
-      void
+      _GLIBCXX20_CONSTEXPR void
       fill(const value_type& __u)
       { std::fill_n(begin(), size(), __u); }
 
-      void
+      _GLIBCXX20_CONSTEXPR void
       swap(array& __other)
       noexcept(_AT_Type::_Is_nothrow_swappable::value)
       { std::swap_ranges(begin(), end(), __other.begin()); }
@@ -282,6 +282,7 @@  namespace __debug
 #endif
 
   template<typename _Tp, std::size_t _Nm>
+    _GLIBCXX20_CONSTEXPR
     inline void
     swap(array<_Tp, _Nm>& __one, array<_Tp, _Nm>& __two)
     noexcept(noexcept(__one.swap(__two)))