diff options
author | Tom Tromey <tom@tromey.com> | 2023-10-15 11:20:57 -0600 |
---|---|---|
committer | Tom Tromey <tom@tromey.com> | 2023-11-29 14:29:44 -0700 |
commit | dead89d27645c391b62da24a2f2942fb8a819d45 (patch) | |
tree | c8495f3c25ec84187a76b617345b8d61c7d8e6f1 /gdbsupport | |
parent | d57f38ec74f12b970f3186ac54a9a0f00bf993c7 (diff) | |
download | gdb-dead89d27645c391b62da24a2f2942fb8a819d45.zip gdb-dead89d27645c391b62da24a2f2942fb8a819d45.tar.gz gdb-dead89d27645c391b62da24a2f2942fb8a819d45.tar.bz2 |
Enable some C++14 code in array-view.h
This changes gdbsupport/array-view.h to enable some code that is
C++14-specific.
Approved-By: Pedro Alves <pedro@palves.net>
Diffstat (limited to 'gdbsupport')
-rw-r--r-- | gdbsupport/array-view.h | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h index 4b51911..0417f9e 100644 --- a/gdbsupport/array-view.h +++ b/gdbsupport/array-view.h @@ -153,18 +153,17 @@ public: : 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 @@ public: } 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]; @@ -188,7 +187,7 @@ public: [[nodiscard]] 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}; @@ -199,7 +198,7 @@ public: [[nodiscard]] 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}; |