[3/7] Enable some C++14 code in array-view.h

Message ID 20231016230527.1820819-4-tom@tromey.com
State New
Headers
Series More C++17 Updates |

Checks

Context Check Description
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_build--master-arm success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-aarch64 success Testing passed
linaro-tcwg-bot/tcwg_gdb_check--master-arm success Testing passed

Commit Message

Tom Tromey Oct. 16, 2023, 11:02 p.m. UTC
  This changes gdbsupport/array-view.h to enable some code that is
C++14-specific.
---
 gdbsupport/array-view.h | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)
  

Patch

diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h
index ee3a3c58710..d58b99fb647 100644
--- a/gdbsupport/array-view.h
+++ b/gdbsupport/array-view.h
@@ -153,18 +153,17 @@  class array_view
     : m_array (c.data ()), m_size (c.size ())
   {}
 
-  /* Observer methods.  Some of these can't be constexpr until we
-     require C++14.  */
-  /*constexpr14*/ T *data () noexcept { return m_array; }
+  /* Observer methods.  */
+  constexpr T *data () noexcept { return m_array; }
   constexpr const T *data () const noexcept { return m_array; }
 
-  /*constexpr14*/ T *begin () noexcept { return m_array; }
+  constexpr T *begin () noexcept { return m_array; }
   constexpr const T *begin () const noexcept { return m_array; }
 
-  /*constexpr14*/ T *end () noexcept { return m_array + m_size; }
+  constexpr T *end () noexcept { return m_array + m_size; }
   constexpr const T *end () const noexcept { return m_array + m_size; }
 
-  /*constexpr14*/ reference operator[] (size_t index) noexcept
+  constexpr reference operator[] (size_t index) noexcept
   {
 #if defined(_GLIBCXX_DEBUG)
     gdb_assert (index < m_size);
@@ -173,7 +172,7 @@  class array_view
   }
   constexpr const_reference operator[] (size_t index) const noexcept
   {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
+#if defined(_GLIBCXX_DEBUG)
     gdb_assert (index < m_size);
 #endif
     return m_array[index];
@@ -187,7 +186,7 @@  class array_view
   /* Return a new array view over SIZE elements starting at START.  */
   constexpr array_view<T> slice (size_type start, size_type size) const noexcept
   {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
+#if defined(_GLIBCXX_DEBUG)
     gdb_assert (start + size <= m_size);
 #endif
     return {m_array + start, size};
@@ -197,7 +196,7 @@  class array_view
      inclusive.  */
   constexpr array_view<T> slice (size_type start) const noexcept
   {
-#if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L
+#if defined(_GLIBCXX_DEBUG)
     gdb_assert (start <= m_size);
 #endif
     return {m_array + start, size () - start};