From c583a2520616c2736cffc389c89a48b159366e6c Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Wed, 8 Feb 2023 15:36:23 -0500 Subject: Run clang-format.sh Change-Id: Ia948cc26d534b0dd02702244d52434b1a2093968 --- gdbsupport/array-view.h | 107 ++++++++++++++++++++++++------------------------ 1 file changed, 54 insertions(+), 53 deletions(-) (limited to 'gdbsupport/array-view.h') diff --git a/gdbsupport/array-view.h b/gdbsupport/array-view.h index 3d8248b..9dd3fab 100644 --- a/gdbsupport/array-view.h +++ b/gdbsupport/array-view.h @@ -64,23 +64,24 @@ You can find unit tests covering the whole API in unittests/array-view-selftests.c. */ -namespace gdb { +namespace gdb +{ -template +template class array_view { /* True iff decayed T is the same as decayed U. E.g., we want to say that 'T&' is the same as 'const T'. */ - template + template using IsDecayedT = typename std::is_same::type, - typename std::decay::type>; + typename std::decay::type>; /* True iff decayed T is the same as decayed U, and 'U *' is implicitly convertible to 'T *'. This is a requirement for several methods. */ - template - using DecayedConvertible = gdb::And, - std::is_convertible>; + template + using DecayedConvertible + = gdb::And, std::is_convertible>; public: using value_type = T; @@ -89,68 +90,66 @@ public: using size_type = size_t; /* Default construction creates an empty view. */ - constexpr array_view () noexcept - : m_array (nullptr), m_size (0) - {} + constexpr array_view () noexcept : m_array (nullptr), m_size (0) {} /* Create an array view over a single object of the type of an array_view element. The created view as size==1. This is templated on U to allow constructing a array_view over a (non-const) T. The "convertible" requirement makes sure that you can't create an array_view over a const T. */ - template>> - constexpr array_view (U &elem) noexcept - : m_array (&elem), m_size (1) - {} + template>> + constexpr array_view (U &elem) noexcept : m_array (&elem), + m_size (1) + { + } /* Same as above, for rvalue references. */ - template>> - constexpr array_view (U &&elem) noexcept - : m_array (&elem), m_size (1) - {} + template>> + constexpr array_view (U &&elem) noexcept : m_array (&elem), + m_size (1) + { + } /* Create an array view from a pointer to an array and an element count. */ - template>> + template>> constexpr array_view (U *array, size_t size) noexcept - : m_array (array), m_size (size) - {} + : m_array (array), + m_size (size) + { + } /* Create an array view from a range. This is templated on both U an V to allow passing in a mix of 'const T *' and 'T *'. */ - template>, - typename = Requires>> + template>, + typename = Requires>> constexpr array_view (U *begin, V *end) noexcept - : m_array (begin), m_size (end - begin) - {} + : m_array (begin), + m_size (end - begin) + { + } /* Create an array view from an array. */ - template>> + template>> constexpr array_view (U (&array)[Size]) noexcept - : m_array (array), m_size (Size) - {} + : m_array (array), + m_size (Size) + { + } /* Create an array view from a contiguous container. E.g., std::vector and std::array. */ template>>, - typename - = Requires ().data ()) - >::type>>, - typename - = Requires ().size ()), - size_type>>> + typename = Requires>>, + typename = Requires ().data ())>::type>>, + typename = Requires ().size ()), size_type>>> constexpr array_view (Container &&c) noexcept - : m_array (c.data ()), m_size (c.size ()) - {} + : m_array (c.data ()), + m_size (c.size ()) + { + } /* Observer methods. Some of these can't be constexpr until we require C++14. */ @@ -184,12 +183,13 @@ public: /* Slice an array view. */ /* Return a new array view over SIZE elements starting at START. */ - constexpr array_view slice (size_type start, size_type size) const noexcept + constexpr array_view slice (size_type start, + size_type size) const noexcept { #if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L gdb_assert (start + size <= m_size); #endif - return {m_array + start, size}; + return { m_array + start, size }; } /* Return a new array view over all the elements after START, @@ -199,7 +199,7 @@ public: #if defined(_GLIBCXX_DEBUG) && __cplusplus >= 201402L gdb_assert (start <= m_size); #endif - return {m_array + start, size () - start}; + return { m_array + start, size () - start }; } private: @@ -211,8 +211,9 @@ private: The two array views must have the same length. */ -template -void copy (gdb::array_view src, gdb::array_view dest) +template +void +copy (gdb::array_view src, gdb::array_view dest) { gdb_assert (dest.size () == src.size ()); if (dest.data () < src.data ()) @@ -225,7 +226,7 @@ void copy (gdb::array_view src, gdb::array_view dest) RHS have the same sizes, and whether each pair of elements of LHS and RHS at the same position compares equal. */ -template +template bool operator== (const gdb::array_view &lhs, const gdb::array_view &rhs) { @@ -241,7 +242,7 @@ operator== (const gdb::array_view &lhs, const gdb::array_view &rhs) /* Compare two array_views for inequality. */ -template +template bool operator!= (const gdb::array_view &lhs, const gdb::array_view &rhs) { @@ -287,7 +288,7 @@ template constexpr inline array_view make_array_view (U *array, size_t size) noexcept { - return {array, size}; + return { array, size }; } } /* namespace gdb */ -- cgit v1.1