From ed3ad1ca9f49b06dc091d24c532d6aa8547754bc Mon Sep 17 00:00:00 2001 From: Marc Emmers Date: Wed, 24 Nov 2021 08:59:25 +0100 Subject: [PATCH 1/2] mstd::span rename index_type to size_type according to spec --- platform/cxxsupport/mstd_span | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/platform/cxxsupport/mstd_span b/platform/cxxsupport/mstd_span index 184f14ee32..a5a2e198f2 100644 --- a/platform/cxxsupport/mstd_span +++ b/platform/cxxsupport/mstd_span @@ -139,7 +139,7 @@ class span { public: using element_type = ElementType; using value_type = typename mstd::remove_cv_t; - using index_type = size_t; + using size_type = size_t; using difference_type = ptrdiff_t; using pointer = element_type *; using const_pointer = const element_type *; @@ -148,7 +148,7 @@ public: using iterator = pointer; using reverse_iterator = std::reverse_iterator; - static constexpr index_type extent = Extent; + static constexpr size_type extent = Extent; // Constructors, copy and assignment template>(*)[], ElementType(*)[]>::value, int> = 0> - constexpr span(It ptr, index_type count) : + constexpr span(It ptr, size_type count) : _storage(ptr, count) { MBED_ASSERT(extent == dynamic_extent || extent == count); @@ -251,32 +251,32 @@ public: return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset}; } - constexpr span first(index_type count) const + constexpr span first(size_type count) const { MBED_ASSERT(count <= size()); return {data(), count}; } - constexpr span last(index_type count) const + constexpr span last(size_type count) const { MBED_ASSERT(count <= size()); return {data() + (size() - count), count}; } constexpr span - subspan(index_type offset, index_type count = dynamic_extent) const + subspan(size_type offset, size_type count = dynamic_extent) const { MBED_ASSERT(offset <= size() && (count == dynamic_extent || count <= size() - offset)); return {data() + offset, count == dynamic_extent ? size() - offset : count }; } // Observers - constexpr index_type size() const noexcept + constexpr size_type size() const noexcept { return _storage._size; } - constexpr index_type size_bytes() const noexcept + constexpr size_type size_bytes() const noexcept { return size() * sizeof(element_type); } @@ -287,7 +287,7 @@ public: } // Element access - constexpr reference operator[](index_type idx) const + constexpr reference operator[](size_type idx) const { MBED_ASSERT(idx < size()); return *(data() + idx); @@ -336,7 +336,7 @@ private: }; template -constexpr span::index_type span::extent; +constexpr span::size_type span::extent; #if __cplusplus >= 201703L || __cpp_deduction_guides >= 201703L // Deduction guides From 0fb88f8521485f6db9a691986110da7310425ec7 Mon Sep 17 00:00:00 2001 From: Marc Emmers Date: Tue, 30 Nov 2021 10:55:53 +0100 Subject: [PATCH 2/2] Deprecate instead of remove index_type --- platform/cxxsupport/mstd_span | 2 ++ 1 file changed, 2 insertions(+) diff --git a/platform/cxxsupport/mstd_span b/platform/cxxsupport/mstd_span index a5a2e198f2..ef0873dd27 100644 --- a/platform/cxxsupport/mstd_span +++ b/platform/cxxsupport/mstd_span @@ -140,6 +140,8 @@ public: using element_type = ElementType; using value_type = typename mstd::remove_cv_t; using size_type = size_t; + // Typedef because IAR does not allow [[deprecated]] with using + [[deprecated("Use size_type instead.")]] typedef size_t index_type; using difference_type = ptrdiff_t; using pointer = element_type *; using const_pointer = const element_type *;