31 #ifndef ETL_ARRAY_VIEW_INCLUDED
32 #define ETL_ARRAY_VIEW_INCLUDED
62 :
exception(reason_, file_name_, line_number_)
76 :
array_view_exception(ETL_ERROR_TEXT(
"array_view:bounds", ETL_FILE
"A"), file_name_, line_number_)
90 :
array_view_exception(ETL_ERROR_TEXT(
"array_view:uninitialised", ETL_FILE
"B"), file_name_, line_number_)
103 typedef T value_type;
104 typedef size_t size_type;
105 typedef const T& const_reference;
106 typedef const T* const_pointer;
107 typedef const T* const_iterator;
108 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
110 #if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
112 typedef T& reference;
114 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
116 typedef const_pointer pointer;
117 typedef const_reference reference;
118 typedef const_pointer iterator;
119 typedef const_reverse_iterator reverse_iterator;
126 : mbegin(ETL_NULLPTR),
135 template <
typename TArray>
145 template <
typename TIterator>
146 ETL_CONSTEXPR
array_view(
const TIterator begin_,
const TIterator end_)
155 template <
typename TIterator,
157 ETL_CONSTEXPR
array_view(
const TIterator begin_,
const TSize size_)
166 template<
size_t ARRAY_SIZE>
169 mend(begin_ + ARRAY_SIZE)
177 : mbegin(other.mbegin),
265 const_iterator
end()
const
273 const_iterator cend()
const
281 reverse_iterator rbegin()
283 return reverse_iterator(mend);
291 return const_reverse_iterator(mend);
299 return const_reverse_iterator(mend);
307 return reverse_iterator(mbegin);
313 const_reverse_iterator
rend()
const
315 return const_reverse_iterator(mbegin);
321 const_reverse_iterator
crend()
const
323 return const_reverse_iterator(mbegin);
331 return (mbegin == mend);
339 return (mend - mbegin);
355 mbegin = other.mbegin;
363 template <
typename TIterator>
364 void assign(
const TIterator begin_,
const TIterator end_)
373 template <
typename TIterator,
375 void assign(
const TIterator begin_,
const TSize size_)
381 #if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
399 #if defined(ETL_ARRAY_VIEW_IS_MUTABLE)
403 reference
at(
const size_t i)
414 const_reference
at(
const size_t i)
const
428 swap(mbegin, other.mbegin);
429 swap(mend, other.mend);
459 return (lhs.
size() == rhs.
size()) &&
468 return !(lhs == rhs);
476 return etl::lexicographical_compare(lhs.
begin(), lhs.
end(), rhs.
begin(), rhs.
end());
512 #if ETL_CPP17_SUPPORTED
513 template <
typename TArray>
514 array_view(TArray& a)
515 -> array_view<typename TArray::value_type>;
517 template <
typename TIterator>
518 array_view(
const TIterator begin_,
const TIterator end_)
519 -> array_view<etl::remove_pointer_t<TIterator>>;
521 template <
typename TIterator,
523 array_view(
const TIterator begin_,
const TSize size_)
524 -> array_view<etl::remove_pointer_t<TIterator>>;
531 template <
typename T>
532 struct hash<
etl::array_view<T> >
536 return etl::private_hash::generic_hash<size_t>(
reinterpret_cast<const uint8_t*
>(&view[0]),
537 reinterpret_cast<const uint8_t*
>(&view[view.
size()]));
546 template <
typename T>
void swap(etl::array_view< T > &lhs, etl::array_view< T > &rhs)
Swaps the values.
Definition: array_view.h:547
The base class for array_view exceptions.
Definition: array_view.h:58
Array view.
Definition: array_view.h:100
iterator begin()
Returns an iterator to the beginning of the array.
Definition: array_view.h:233
const_reverse_iterator crbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition: array_view.h:297
friend bool operator!=(const array_view< T > &lhs, const array_view< T > &rhs)
Inequality for array views.
Definition: array_view.h:466
array_view & operator=(const array_view &other)
Assign from a view.
Definition: array_view.h:353
reference front()
Returns a reference to the first element.
Definition: array_view.h:185
const_reference back() const
Returns a const reference to the last element.
Definition: array_view.h:209
friend bool operator<=(const array_view< T > &lhs, const array_view< T > &rhs)
Less-than-equal for array views.
Definition: array_view.h:490
pointer data()
Returns a pointer to the first element of the internal storage.
Definition: array_view.h:217
iterator end()
Returns an iterator to the end of the array.
Definition: array_view.h:257
const_reverse_iterator rbegin() const
Returns a const reverse iterator to the reverse beginning of the array.
Definition: array_view.h:289
void remove_prefix(const size_type n)
Shrinks the view by moving its start forward.
Definition: array_view.h:435
void swap(array_view &other)
Swaps with another array_view.
Definition: array_view.h:424
const_reference front() const
Returns a const reference to the first element.
Definition: array_view.h:193
const_reverse_iterator rend() const
Returns a const reverse iterator to the end of the array.
Definition: array_view.h:313
const_reference at(const size_t i) const
Returns a const reference to the indexed value.
Definition: array_view.h:414
const_iterator cbegin() const
Returns a const iterator to the beginning of the array.
Definition: array_view.h:249
ETL_CONSTEXPR array_view()
Default constructor.
Definition: array_view.h:125
const_pointer data() const
Returns a const pointer to the first element of the internal storage.
Definition: array_view.h:225
size_t size() const
Returns the size of the array.
Definition: array_view.h:337
void remove_suffix(const size_type n)
Shrinks the view by moving its end backward.
Definition: array_view.h:446
friend bool operator>(const array_view< T > &lhs, const array_view< T > &rhs)
Greater-than for array views.
Definition: array_view.h:482
friend bool operator==(const array_view< T > &lhs, const array_view< T > &rhs)
Equality for array views.
Definition: array_view.h:457
bool empty() const
Returns true if the array size is zero.
Definition: array_view.h:329
const_reverse_iterator crend() const
Returns a const reverse iterator to the end of the array.
Definition: array_view.h:321
const_reference operator[](const size_t i) const
Returns a const reference to the indexed value.
Definition: array_view.h:394
friend bool operator>=(const array_view< T > &lhs, const array_view< T > &rhs)
Greater-than-equal for array views.
Definition: array_view.h:498
reverse_iterator rend()
Returns a reverse iterator to the end of the array.
Definition: array_view.h:305
const_iterator end() const
Returns a const iterator to the end of the array.
Definition: array_view.h:265
size_t max_size() const
Returns the maximum possible size of the array.
Definition: array_view.h:345
void assign(const TIterator begin_, const TIterator end_)
Assign from iterators.
Definition: array_view.h:364
void assign(const TIterator begin_, const TSize size_)
Assign from iterator and size.
Definition: array_view.h:375
const_iterator begin() const
Returns a const iterator to the beginning of the array.
Definition: array_view.h:241
friend bool operator<(const array_view< T > &lhs, const array_view< T > &rhs)
Less-than for array views.
Definition: array_view.h:474
reference back()
Returns a reference to the last element.
Definition: array_view.h:201
#define ETL_ASSERT(b, e)
Definition: error_handler.h:290
exception(string_type reason_, string_type file_, numeric_type line_)
Constructor.
Definition: exception.h:67
Definition: exception.h:47
T * addressof(T &t)
Definition: memory.h:61
Definition: array_view.h:72
Definition: array_view.h:86
Definition: absolute.h:37