diff --git a/platform/cxxsupport/mstd_span b/platform/cxxsupport/mstd_span index 184f14ee32a..ef0873dd275 100644 --- a/platform/cxxsupport/mstd_span +++ b/platform/cxxsupport/mstd_span @@ -139,7 +139,9 @@ 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; + // 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 *; @@ -148,7 +150,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 +253,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 +289,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 +338,7 @@ private: }; template -constexpr span::index_type span::extent; +constexpr span::size_type span::extent; #if __cplusplus >= 201703L || __cpp_deduction_guides >= 201703L // Deduction guides