mirror of https://github.com/ARMmbed/mbed-os.git
mstd::span rename index_type to size_type according to spec
parent
f609a5234e
commit
ed3ad1ca9f
|
@ -139,7 +139,7 @@ class span {
|
||||||
public:
|
public:
|
||||||
using element_type = ElementType;
|
using element_type = ElementType;
|
||||||
using value_type = typename mstd::remove_cv_t<element_type>;
|
using value_type = typename mstd::remove_cv_t<element_type>;
|
||||||
using index_type = size_t;
|
using size_type = size_t;
|
||||||
using difference_type = ptrdiff_t;
|
using difference_type = ptrdiff_t;
|
||||||
using pointer = element_type *;
|
using pointer = element_type *;
|
||||||
using const_pointer = const element_type *;
|
using const_pointer = const element_type *;
|
||||||
|
@ -148,7 +148,7 @@ public:
|
||||||
using iterator = pointer;
|
using iterator = pointer;
|
||||||
using reverse_iterator = std::reverse_iterator<iterator>;
|
using reverse_iterator = std::reverse_iterator<iterator>;
|
||||||
|
|
||||||
static constexpr index_type extent = Extent;
|
static constexpr size_type extent = Extent;
|
||||||
|
|
||||||
// Constructors, copy and assignment
|
// Constructors, copy and assignment
|
||||||
template<size_t E = Extent,
|
template<size_t E = Extent,
|
||||||
|
@ -160,7 +160,7 @@ public:
|
||||||
typename mstd::enable_if_t<mstd::is_convertible<
|
typename mstd::enable_if_t<mstd::is_convertible<
|
||||||
remove_reference_t<mstd::iter_reference_t<It>>(*)[],
|
remove_reference_t<mstd::iter_reference_t<It>>(*)[],
|
||||||
ElementType(*)[]>::value, int> = 0>
|
ElementType(*)[]>::value, int> = 0>
|
||||||
constexpr span(It ptr, index_type count) :
|
constexpr span(It ptr, size_type count) :
|
||||||
_storage(ptr, count)
|
_storage(ptr, count)
|
||||||
{
|
{
|
||||||
MBED_ASSERT(extent == dynamic_extent || extent == count);
|
MBED_ASSERT(extent == dynamic_extent || extent == count);
|
||||||
|
@ -251,32 +251,32 @@ public:
|
||||||
return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset};
|
return {data() + Offset, Count != dynamic_extent ? Count : size() - Offset};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr span<element_type, dynamic_extent> first(index_type count) const
|
constexpr span<element_type, dynamic_extent> first(size_type count) const
|
||||||
{
|
{
|
||||||
MBED_ASSERT(count <= size());
|
MBED_ASSERT(count <= size());
|
||||||
return {data(), count};
|
return {data(), count};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr span<element_type, dynamic_extent> last(index_type count) const
|
constexpr span<element_type, dynamic_extent> last(size_type count) const
|
||||||
{
|
{
|
||||||
MBED_ASSERT(count <= size());
|
MBED_ASSERT(count <= size());
|
||||||
return {data() + (size() - count), count};
|
return {data() + (size() - count), count};
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr span<element_type, dynamic_extent>
|
constexpr span<element_type, dynamic_extent>
|
||||||
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));
|
MBED_ASSERT(offset <= size() && (count == dynamic_extent || count <= size() - offset));
|
||||||
return {data() + offset, count == dynamic_extent ? size() - offset : count };
|
return {data() + offset, count == dynamic_extent ? size() - offset : count };
|
||||||
}
|
}
|
||||||
|
|
||||||
// Observers
|
// Observers
|
||||||
constexpr index_type size() const noexcept
|
constexpr size_type size() const noexcept
|
||||||
{
|
{
|
||||||
return _storage._size;
|
return _storage._size;
|
||||||
}
|
}
|
||||||
|
|
||||||
constexpr index_type size_bytes() const noexcept
|
constexpr size_type size_bytes() const noexcept
|
||||||
{
|
{
|
||||||
return size() * sizeof(element_type);
|
return size() * sizeof(element_type);
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
// Element access
|
// Element access
|
||||||
constexpr reference operator[](index_type idx) const
|
constexpr reference operator[](size_type idx) const
|
||||||
{
|
{
|
||||||
MBED_ASSERT(idx < size());
|
MBED_ASSERT(idx < size());
|
||||||
return *(data() + idx);
|
return *(data() + idx);
|
||||||
|
@ -336,7 +336,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
template<typename ElementType, size_t Extent>
|
template<typename ElementType, size_t Extent>
|
||||||
constexpr span<ElementType, Extent>::index_type span<ElementType, Extent>::extent;
|
constexpr span<ElementType, Extent>::size_type span<ElementType, Extent>::extent;
|
||||||
|
|
||||||
#if __cplusplus >= 201703L || __cpp_deduction_guides >= 201703L
|
#if __cplusplus >= 201703L || __cpp_deduction_guides >= 201703L
|
||||||
// Deduction guides
|
// Deduction guides
|
||||||
|
|
Loading…
Reference in New Issue