31 #ifndef ETL_SPAN_INCLUDED
32 #define ETL_SPAN_INCLUDED
57 template <
typename T, const
size_t EXTENT = etl::dynamic_extent>
62 typedef T element_type;
63 typedef typename etl::remove_cv<T>::type value_type;
64 typedef size_t size_type;
66 typedef const T& const_reference;
68 typedef const T* const_pointer;
70 typedef const T* const_iterator;
71 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
72 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
74 static ETL_CONSTANT
size_t extent = EXTENT;
79 ETL_CONSTEXPR
span() ETL_NOEXCEPT
89 template <
typename TSpan>
90 ETL_CONSTEXPR
span(TSpan& a) ETL_NOEXCEPT
92 , mend(a.data() + a.size())
100 template <
typename TSpan>
101 ETL_CONSTEXPR
span(
const TSpan& a) ETL_NOEXCEPT
103 , mend(a.data() + a.size())
110 template <
typename TIterator>
111 ETL_CONSTEXPR
span(
const TIterator begin_,
const TIterator end_)
120 template <
typename TIterator,
typename TSize>
121 ETL_CONSTEXPR
span(
const TIterator begin_,
const TSize size_) ETL_NOEXCEPT
130 template<const
size_t ARRAY_SIZE>
131 ETL_CONSTEXPR
span(element_type(&begin_)[ARRAY_SIZE]) ETL_NOEXCEPT
133 , mend(begin_ + ARRAY_SIZE)
141 : mbegin(other.mbegin)
149 ETL_CONSTEXPR reference
front() const ETL_NOEXCEPT
157 ETL_CONSTEXPR reference
back() const ETL_NOEXCEPT
165 ETL_CONSTEXPR pointer
data() const ETL_NOEXCEPT
173 ETL_CONSTEXPR iterator
begin() const ETL_NOEXCEPT
181 ETL_CONSTEXPR iterator
end() const ETL_NOEXCEPT
197 ETL_CONSTEXPR reverse_iterator
rend() const ETL_NOEXCEPT
199 return reverse_iterator(mbegin);
205 ETL_CONSTEXPR
bool empty() const ETL_NOEXCEPT
207 return (mbegin == mend);
213 ETL_CONSTEXPR
size_t size() const ETL_NOEXCEPT
215 return (mend - mbegin);
223 return sizeof(element_type) * (mend - mbegin);
239 mbegin = other.mbegin;
255 template <const
size_t COUNT>
272 template <const
size_t COUNT>
290 template <const
size_t OFFSET, const
size_t COUNT = etl::dynamic_extent>
292 typename etl::enable_if<COUNT == etl::dynamic_extent,
etl::span<element_type, ((EXTENT != etl::dynamic_extent) ? EXTENT - OFFSET : etl::dynamic_extent)> >::type
295 return etl::span<element_type, ((EXTENT != etl::dynamic_extent) ? EXTENT - OFFSET : etl::dynamic_extent)>(mbegin + OFFSET, mend);
302 template <const
size_t OFFSET, const
size_t COUNT = etl::dynamic_extent>
315 if (count == etl::dynamic_extent)
324 element_type* mbegin;
331 #if ETL_CPP17_SUPPORTED
332 template <
typename TArray>
334 ->span<
typename TArray::value_type>;
336 template <
typename TIterator>
337 span(
const TIterator begin_,
const TIterator end_)
338 ->span<etl::remove_pointer_t<TIterator>>;
340 template <
typename TIterator,
342 span(
const TIterator begin_,
const TSize size_)
343 ->span<etl::remove_pointer_t<TIterator>>;
350 template <
typename T>
351 struct hash<
etl::span<T> >
355 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(&view[0]),
356 reinterpret_cast<const uint8_t*
>(&view[view.
size()]));
Definition: iterator.h:251
Array view.
Definition: span.h:59
ETL_CONSTEXPR14 span & operator=(const span &other) ETL_NOEXCEPT
Assign from a span.
Definition: span.h:237
ETL_CONSTEXPR etl::enable_if< COUNT !=etl::dynamic_extent, etl::span< element_type, COUNT > >::type subspan() const
Definition: span.h:305
ETL_CONSTEXPR span() ETL_NOEXCEPT
Default constructor.
Definition: span.h:79
ETL_CONSTEXPR reference back() const ETL_NOEXCEPT
Returns a reference to the last element.
Definition: span.h:157
ETL_CONSTEXPR etl::span< element_type, COUNT > last() const
Obtains a span that is a view over the last COUNT elements of this span.
Definition: span.h:273
ETL_CONSTEXPR iterator end() const ETL_NOEXCEPT
Returns an iterator to the end of the span.
Definition: span.h:181
ETL_CONSTEXPR iterator begin() const ETL_NOEXCEPT
Returns an iterator to the beginning of the span.
Definition: span.h:173
ETL_CONSTEXPR etl::span< element_type, COUNT > first() const
Obtains a span that is a view over the first COUNT elements of this span.
Definition: span.h:256
ETL_CONSTEXPR pointer data() const ETL_NOEXCEPT
Returns a pointer to the first element of the internal storage.
Definition: span.h:165
ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the span size is zero.
Definition: span.h:205
ETL_CONSTEXPR reference front() const ETL_NOEXCEPT
Returns a reference to the first element.
Definition: span.h:149
ETL_CONSTEXPR size_t size_bytes() const ETL_NOEXCEPT
Returns the size of the span in bytes.
Definition: span.h:221
ETL_CONSTEXPR etl::enable_if< COUNT==etl::dynamic_extent, etl::span< element_type,((EXTENT !=etl::dynamic_extent) ? EXTENT - OFFSET :etl::dynamic_extent)> >::type subspan() const
Definition: span.h:293
ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the span.
Definition: span.h:229
ETL_CONSTEXPR reference operator[](const size_t i) const
Returns a reference to the indexed value.
Definition: span.h:247
ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the span.
Definition: span.h:213
ETL_CONSTEXPR reverse_iterator rend() const ETL_NOEXCEPT
Returns a reverse iterator to the end of the span.
Definition: span.h:197
Definition: integral_limits.h:54
T * addressof(T &t)
Definition: memory.h:61
enable_if
Definition: type_traits_generator.h:1228
extent
Definition: type_traits_generator.h:1239
Definition: absolute.h:37