31#ifndef ETL_ARRAY_INCLUDED
32#define ETL_ARRAY_INCLUDED
41#include "static_assert.h"
62 array_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
63 :
exception(reason_, file_name_, line_number_)
86 template <
typename T,
size_t SIZE_>
95 static ETL_CONSTANT
size_t SIZE = SIZE_;
98 typedef size_t size_type;
99 typedef ptrdiff_t difference_type;
100 typedef T& reference;
101 typedef const T& const_reference;
103 typedef const T* const_pointer;
105 typedef const T* const_iterator;
106 typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
107 typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
118 reference
at(
size_t i)
130#if defined(ETL_THROW_EXCEPTIONS)
135 const_reference
at(
size_t i)
const
177 ETL_CONSTEXPR const_reference
front()
const
195 ETL_CONSTEXPR const_reference
back()
const
213 ETL_CONSTEXPR const_pointer
data() const ETL_NOEXCEPT
235 ETL_CONSTEXPR const_iterator
begin() const ETL_NOEXCEPT
244 ETL_CONSTEXPR const_iterator
cbegin() const ETL_NOEXCEPT
253 iterator
end() ETL_NOEXCEPT
262 ETL_CONSTEXPR const_iterator
end() const ETL_NOEXCEPT
271 ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
280 reverse_iterator rbegin() ETL_NOEXCEPT
282 return reverse_iterator(
end());
289 ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
291 return const_reverse_iterator(
end());
298 ETL_CONSTEXPR const_reverse_iterator
crbegin() const ETL_NOEXCEPT
300 return const_reverse_iterator(
end());
307 reverse_iterator
rend() ETL_NOEXCEPT
309 return reverse_iterator(
begin());
316 ETL_CONSTEXPR const_reverse_iterator
rend() const ETL_NOEXCEPT
318 return const_reverse_iterator(
begin());
325 ETL_CONSTEXPR const_reverse_iterator
crend() const ETL_NOEXCEPT
327 return const_reverse_iterator(
begin());
338 ETL_CONSTEXPR
bool empty() const ETL_NOEXCEPT
347 ETL_CONSTEXPR
size_t size() const ETL_NOEXCEPT
369 ETL_CONSTEXPR14
void fill(parameter_t value)
382 for (
size_t i = 0UL; i < SIZE; ++i)
394 template <
typename TIterator>
395 void assign(TIterator first,
const TIterator last)
406 template <
typename TIterator>
407 void assign(TIterator first,
const TIterator last, parameter_t value)
410 iterator p = etl::copy(first, last,
begin());
413 etl::fill(p,
end(), value);
421 inline iterator
insert_at(
size_t position, parameter_t value)
431 iterator
insert(const_iterator position, parameter_t value)
433 iterator p = to_iterator(position);
435 etl::move_backward(p,
end() - 1,
end());
447 template <
typename TIterator>
448 inline iterator
insert_at(
size_t position, TIterator first,
const TIterator last)
459 template <
typename TIterator>
460 iterator
insert(const_iterator position, TIterator first,
const TIterator last)
462 iterator p = to_iterator(position);
465 size_t source_size = etl::distance(first, last);
466 size_t destination_space = etl::distance(position, cend());
469 if (source_size < destination_space)
471 size_t length = SIZE - (etl::distance(
begin(), p) + source_size);
472 etl::move_backward(p, p + length,
end());
496 iterator
erase(const_iterator position)
498 iterator p = to_iterator(position);
499 etl::move(p + 1,
end(), p);
521 iterator
erase(const_iterator first, const_iterator last)
523 iterator p = to_iterator(first);
524 etl::move(last, cend(), p);
533 inline iterator
erase_at(
size_t position, parameter_t value)
543 iterator
erase(const_iterator position, parameter_t value)
545 iterator p = to_iterator(position);
547 etl::move(p + 1,
end(), p);
559 iterator
erase_range(
size_t first,
size_t last, parameter_t value)
569 iterator
erase(const_iterator first, const_iterator last, parameter_t value)
571 iterator p = to_iterator(first);
573 p = etl::move(last, cend(), p);
574 etl::fill(p,
end(), value);
576 return to_iterator(first);
587 iterator to_iterator(const_iterator itr)
const
589 return const_cast<iterator
>(itr);
593 template <
typename T,
size_t SIZE_>
594 ETL_CONSTANT
size_t array<T, SIZE_>::SIZE;
600 template <
typename... T>
601 array(T...) -> array<
typename etl::common_type<T...>::type,
sizeof...(T)>;
607#if ETL_HAS_INITIALIZER_LIST
608 template <
typename T,
typename... TValues>
609 constexpr auto make_array(TValues&&... values) ->
etl::array<T,
sizeof...(TValues)>
611 return { { etl::forward<T>(values)... } };
620 template <
typename T, const
size_t SIZE>
632 template <
typename T,
size_t SIZE>
635 return etl::equal(lhs.
cbegin(), lhs.cend(), rhs.
cbegin());
644 template <
typename T,
size_t SIZE>
647 return !(lhs == rhs);
656 template <
typename T,
size_t SIZE>
659 return etl::lexicographical_compare(lhs.
cbegin(),
671 template <
typename T,
size_t SIZE>
682 template <
typename T,
size_t SIZE>
695 template <
typename T,
size_t SIZE>
709 template <
size_t I,
typename T,
size_t MAXN>
712 ETL_STATIC_ASSERT(I < MAXN,
"Index out of bounds");
724 template <
size_t I,
typename T,
size_t MAXN>
727 ETL_STATIC_ASSERT(I < MAXN,
"Index out of bounds");
ETL_CONSTEXPR14 etl::enable_if< etl::is_random_iterator< TInputIterator >::value &&etl::is_random_iterator< TOutputIterator >::value, TOutputIterator >::type copy_s(TInputIterator i_begin, TInputIterator i_end, TOutputIterator o_begin, TOutputIterator o_end)
Definition: algorithm.h:2008
ETL_NODISCARD reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition: array.h:307
ETL_NODISCARD reference front()
Returns a reference to the first element.
Definition: array.h:168
iterator erase(const_iterator first, const_iterator last)
Definition: array.h:521
ETL_CONSTEXPR14 void swap(array &other) ETL_NOEXCEPT
Definition: array.h:378
void assign(TIterator first, const TIterator last)
Definition: array.h:395
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition: array.h:298
T _buffer[SIZE]
The array data.
Definition: array.h:580
iterator erase_range(size_t first, size_t last)
Definition: array.h:510
ETL_NODISCARD reference at(size_t i)
Definition: array.h:118
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition: array.h:369
ETL_NODISCARD ETL_CONSTEXPR const_reference at(size_t i) const
Definition: array.h:135
iterator insert_at(size_t position, parameter_t value)
Definition: array.h:421
iterator erase_range(size_t first, size_t last, parameter_t value)
Definition: array.h:559
void assign(TIterator first, const TIterator last, parameter_t value)
Definition: array.h:407
iterator erase_at(size_t position)
Definition: array.h:486
iterator erase(const_iterator first, const_iterator last, parameter_t value)
Definition: array.h:569
iterator erase(const_iterator position, parameter_t value)
Definition: array.h:543
ETL_NODISCARD iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition: array.h:226
iterator insert(const_iterator position, parameter_t value)
Definition: array.h:431
ETL_NODISCARD iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition: array.h:253
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition: array.h:325
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition: array.h:338
ETL_NODISCARD reference operator[](size_t i)
Definition: array.h:148
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition: array.h:347
ETL_NODISCARD pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition: array.h:204
iterator insert(const_iterator position, TIterator first, const TIterator last)
Definition: array.h:460
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition: array.h:244
iterator erase(const_iterator position)
Definition: array.h:496
iterator erase_at(size_t position, parameter_t value)
Definition: array.h:533
iterator insert_at(size_t position, TIterator first, const TIterator last)
Definition: array.h:448
ETL_NODISCARD reference back()
Returns a reference to the last element.
Definition: array.h:186
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition: array.h:356
#define ETL_ASSERT(b, e)
Definition: error_handler.h:316
ETL_CONSTEXPR exception(string_type reason_, string_type, numeric_type line_)
Constructor.
Definition: exception.h:69
Definition: exception.h:47
bitset_ext
Definition: absolute.h:38
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:684
T & get(array< T, MAXN > &a)
Definition: array.h:710
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:696
bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:645
void swap(etl::array< T, SIZE > &lhs, etl::array< T, SIZE > &rhs)
Template deduction guides.
Definition: array.h:621
bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:633
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:657
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition: array.h:672
etl::conditional< etl::is_fundamental< T >::value||etl::is_pointer< T >::value, T, constT & >::type type
By default fundamental and pointer types are passed by value.
Definition: parameter_type.h:48