Loading...
Searching...
No Matches
array.h
Go to the documentation of this file.
/******************************************************************************
The MIT License(MIT)
Embedded Template Library.
https://github.com/ETLCPP/etl
https://www.etlcpp.com
Copyright(c) 2014 John Wellbelove
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files(the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and / or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions :
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
******************************************************************************/
#ifndef ETL_ARRAY_INCLUDED
#define ETL_ARRAY_INCLUDED
#include "platform.h"
#include "algorithm.h"
#include "error_handler.h"
#include "exception.h"
#include "iterator.h"
#include "parameter_type.h"
#include "static_assert.h"
#include "type_traits.h"
#include <stddef.h>
namespace etl
{
//***************************************************************************
//***************************************************************************
class array_exception : public exception
{
public:
array_exception(string_type reason_, string_type file_name_, numeric_type line_number_)
: exception(reason_, file_name_, line_number_)
{
}
};
//***************************************************************************
//***************************************************************************
class array_out_of_range : public array_exception
{
public:
array_out_of_range(string_type file_name_, numeric_type line_number_)
: array_exception("array:range", file_name_, line_number_)
{
}
};
//***************************************************************************
//***************************************************************************
template <typename T, size_t SIZE_>
class array
{
private:
typedef typename etl::parameter_type<T>::type parameter_t;
public:
static ETL_CONSTANT size_t SIZE = SIZE_;
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//*************************************************************************
// Element access
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
{
ETL_ASSERT(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS || ETL_NOT_CHECKING_INDEX_OPERATOR)
{
// Throwing from c++11 constexpr requires special syntax
#if ETL_USING_CPP11 && ETL_NOT_USING_CPP14 && ETL_USING_EXCEPTIONS && ETL_CHECKING_INDEX_OPERATOR
return i < SIZE ? _buffer[i] : throw(ETL_ERROR(array_out_of_range));
#else
ETL_ASSERT_CHECK_INDEX_OPERATOR(i < SIZE, ETL_ERROR(array_out_of_range));
return _buffer[i];
#endif
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
return _buffer[0];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
return _buffer[0];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
return _buffer[SIZE - 1];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
{
ETL_STATIC_ASSERT(SIZE > 0, "Array is empty.");
return _buffer[SIZE - 1];
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
{
return _buffer;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
{
return _buffer;
}
//*************************************************************************
// Iterators
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
{
return _buffer;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
{
return _buffer;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
{
return begin();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
{
return _buffer + SIZE;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
{
return _buffer + SIZE;
}
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
{
return _buffer + SIZE;
}
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(begin());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(begin());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(begin());
}
//*************************************************************************
// Capacity
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
{
return (SIZE == 0);
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return SIZE;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return SIZE;
}
//*************************************************************************
// Operations
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void fill(parameter_t value)
{
etl::fill(_buffer, _buffer + SIZE, value);
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void swap(array& other) ETL_NOEXCEPT_FROM(ETL_OR_STD::swap(etl::declval<T&>(), etl::declval<T&>()))
{
using ETL_OR_STD::swap; // Allow ADL
for (size_t i = 0UL; i < SIZE; ++i)
{
swap(_buffer[i], other._buffer[i]);
}
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator assign(TIterator first, const TIterator last)
{
return etl::copy_s(first, last, begin(), end());
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator assign(TIterator first, const TIterator last, parameter_t value)
{
// Copy from the range.
iterator p = etl::copy_s(first, last, begin(), end());
// Initialise any that are left.
etl::fill(p, end(), value);
return p;
}
//*************************************************************************
//*************************************************************************
inline iterator insert_at(size_t position, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
return insert(begin() + position, value);
}
//*************************************************************************
//*************************************************************************
iterator insert(const_iterator position, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(position);
etl::move_backward(p, end() - 1, end());
*p = value;
return p;
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
inline iterator insert_at(size_t position, TIterator first, const TIterator last)
{
ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
return insert(begin() + position, first, last);
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator insert(const_iterator position, TIterator first, const TIterator last)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(position);
iterator result(p);
size_t source_size = static_cast<size_t>(etl::distance(first, last));
size_t destination_space = static_cast<size_t>(etl::distance(position, cend()));
// Do we need to move anything?
if (source_size < destination_space)
{
size_t length = SIZE - (static_cast<size_t>(etl::distance(begin(), p)) + source_size);
etl::move_backward(p, p + length, end());
}
// Copy from the range.
etl::copy_s(first, last, p, end());
return result;
}
//*************************************************************************
//*************************************************************************
inline iterator erase_at(size_t position)
{
ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
return erase(begin() + position);
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator position)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(position);
etl::move(p + 1, end(), p);
return p;
}
//*************************************************************************
//*************************************************************************
iterator erase_range(size_t first, size_t last)
{
ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
return erase(begin() + first, begin() + last);
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator first, const_iterator last)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(first);
etl::move(last, cend(), p);
return p;
}
//*************************************************************************
//*************************************************************************
inline iterator erase_at(size_t position, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(position < SIZE, ETL_ERROR(array_out_of_range));
return erase(begin() + position, value);
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator position, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= position && position < cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(position);
etl::move(p + 1, end(), p);
back() = value;
return p;
}
//*************************************************************************
//*************************************************************************
iterator erase_range(size_t first, size_t last, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(first <= last && last <= SIZE, ETL_ERROR(array_out_of_range));
return erase(begin() + first, begin() + last, value);
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator first, const_iterator last, parameter_t value)
{
ETL_ASSERT_CHECK_EXTRA(cbegin() <= first && first <= last && last <= cend(), ETL_ERROR(array_out_of_range));
iterator p = to_iterator(first);
p = etl::move(last, cend(), p);
etl::fill(p, end(), value);
return to_iterator(first);
}
T _buffer[SIZE];
private:
//*************************************************************************
//*************************************************************************
iterator to_iterator(const_iterator itr) const
{
return const_cast<iterator>(itr);
}
};
template <typename T, size_t SIZE_>
ETL_CONSTANT size_t array<T, SIZE_>::SIZE;
//***************************************************************************
//***************************************************************************
template <typename T>
class array<T, 0>
{
private:
typedef typename etl::parameter_type<T>::type parameter_t;
public:
static ETL_CONSTANT size_t SIZE = 0;
typedef T value_type;
typedef size_t size_type;
typedef ptrdiff_t difference_type;
typedef T& reference;
typedef const T& const_reference;
typedef T* pointer;
typedef const T* const_pointer;
typedef T* iterator;
typedef const T* const_iterator;
typedef ETL_OR_STD::reverse_iterator<iterator> reverse_iterator;
typedef ETL_OR_STD::reverse_iterator<const_iterator> const_reverse_iterator;
//*************************************************************************
// Element access
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
{
return *data();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
{
return (T*)0;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
{
return (const T*)0;
}
//*************************************************************************
// Iterators
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
{
return const_iterator();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
{
return const_iterator();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
{
return const_iterator();
}
//*************************************************************************
// Returns a const iterator to the end of the array.
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_iterator cend() const ETL_NOEXCEPT
{
return const_iterator();
}
//*************************************************************************
// Returns an reverse iterator to the reverse beginning of the array.
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rbegin() ETL_NOEXCEPT
{
return reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crbegin() const ETL_NOEXCEPT
{
return const_reverse_iterator(end());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
{
return reverse_iterator(begin());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
{
return const_reverse_iterator(begin());
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator crend() const ETL_NOEXCEPT
{
return const_reverse_iterator(begin());
}
//*************************************************************************
// Capacity
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
{
return true;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
{
return 0;
}
//*************************************************************************
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
{
return 0;
}
//*************************************************************************
// Operations
//*************************************************************************
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
{
}
//*************************************************************************
//*************************************************************************
ETL_CONSTEXPR14 void swap(array&) ETL_NOEXCEPT
{
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
inline iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
inline iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
template <typename TIterator>
iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
inline iterator erase_at(size_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase_range(size_t, size_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
inline iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
//*************************************************************************
//*************************************************************************
iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
{
return iterator();
}
};
//*************************************************************************
//*************************************************************************
#if ETL_USING_CPP17
template <typename... T>
array(T...) -> array<typename etl::common_type<T...>::type, sizeof...(T)>;
#endif
//*************************************************************************
//*************************************************************************
#if ETL_HAS_INITIALIZER_LIST
template <typename T, typename... TValues>
constexpr auto make_array(TValues&&... values) ETL_NOEXCEPT -> etl::array<T, sizeof...(TValues)>
{
return {etl::forward<T>(values)...};
}
#endif
//*************************************************************************
//*************************************************************************
template <typename T, const size_t SIZE>
void swap(etl::array<T, SIZE>& lhs, etl::array<T, SIZE>& rhs)
{
lhs.swap(rhs);
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t SIZE>
ETL_CONSTEXPR14 bool operator==(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return etl::equal(lhs.cbegin(), lhs.cend(), rhs.cbegin());
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t SIZE>
ETL_CONSTEXPR14 bool operator!=(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return !(lhs == rhs);
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t SIZE>
bool operator<(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return etl::lexicographical_compare(lhs.cbegin(), lhs.cend(), rhs.cbegin(), rhs.cend());
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t SIZE>
bool operator<=(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return !(lhs > rhs);
}
//*************************************************************************
template <typename T, size_t SIZE>
//*************************************************************************
bool operator>(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return (rhs < lhs);
}
//*************************************************************************
//*************************************************************************
template <typename T, size_t SIZE>
bool operator>=(const etl::array<T, SIZE>& lhs, const etl::array<T, SIZE>& rhs)
{
return !(lhs < rhs);
}
//*************************************************************************
//*************************************************************************
template <size_t Index, typename T, size_t Size>
inline T& get(array<T, Size>& a)
{
ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
return a[Index];
}
//*************************************************************************
//*************************************************************************
template <size_t Index, typename T, size_t Size>
inline const T& get(const array<T, Size>& a)
{
ETL_STATIC_ASSERT(Index < Size, "Index out of bounds");
return a[Index];
}
} // namespace etl
#endif
algorithm.h
error_handler.h
exception.h
etl::copy_s
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:2675
etl::const_iterator
etl::array< T, 0 >::at
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t) ETL_NOEXCEPT
Definition array.h:651
etl::array::operator[]
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:137
etl::array< T, 0 >::rend
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:820
etl::array< T, 0 >::operator[]
ETL_NODISCARD ETL_CONSTEXPR14 reference operator[](size_t) ETL_NOEXCEPT
Definition array.h:670
etl::array::erase
iterator erase(const_iterator first, const_iterator last)
Definition array.h:525
etl::array::rend
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:296
etl::array< T, 0 >::erase_at
iterator erase_at(size_t) ETL_NOEXCEPT
Definition array.h:958
etl::array< T, 0 >::front
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:696
etl::array< T, 0 >::operator[]
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t) const ETL_NOEXCEPT
Definition array.h:680
etl::array< T, 0 >::assign
iterator assign(TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:890
etl::array::front
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:164
etl::array< T, 0 >::data
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal buffer.
Definition array.h:728
etl::array::crbegin
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:288
etl::array::rbegin
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:280
etl::array< T, 0 >::end
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:764
etl::array::begin
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:224
etl::array< delegate_type, Max_Observers >::_buffer
delegate_type _buffer[SIZE]
Definition array.h:599
etl::array::begin
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:232
etl::array< T, 0 >::insert_at
iterator insert_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:914
etl::array< T, 0 >::crend
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:828
etl::array< T, 0 >::erase_range
iterator erase_range(size_t, size_t) ETL_NOEXCEPT
Definition array.h:979
etl::array::operator[]
ETL_NODISCARD ETL_CONSTEXPR const_reference operator[](size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS||ETL_NOT_CHECKING_INDEX_OPERATOR)
Definition array.h:149
etl::array::data
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:204
etl::array< T, 0 >::erase_range
iterator erase_range(size_t, size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1024
etl::array::erase_range
iterator erase_range(size_t first, size_t last)
Definition array.h:512
etl::array< T, 0 >::fill
ETL_CONSTEXPR14 void fill(parameter_t) ETL_NOEXCEPT
Definition array.h:869
etl::array::back
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const ETL_NOEXCEPT
Returns a const reference to the last element.
Definition array.h:194
etl::array::back
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:184
etl::array< T, 0 >::begin
ETL_NODISCARD ETL_CONSTEXPR14 iterator begin() ETL_NOEXCEPT
Returns an iterator to the beginning of the array.
Definition array.h:740
etl::array::fill
ETL_CONSTEXPR14 void fill(parameter_t value)
Definition array.h:353
etl::array< T, 0 >::insert_at
iterator insert_at(size_t, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:936
etl::array< T, 0 >::erase
iterator erase(const_iterator) ETL_NOEXCEPT
Definition array.h:968
etl::array::insert_at
iterator insert_at(size_t position, parameter_t value)
Definition array.h:411
etl::array< T, 0 >::assign
iterator assign(TIterator, const TIterator, parameter_t) ETL_NOEXCEPT
Definition array.h:904
etl::array::erase_range
iterator erase_range(size_t first, size_t last, parameter_t value)
Definition array.h:572
etl::array::at
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t i) const ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:125
etl::array::end
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:256
etl::array< T, 0 >::insert
iterator insert(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:924
etl::array< T, 0 >::max_size
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:856
etl::array< T, 0 >::end
ETL_NODISCARD ETL_CONSTEXPR const_iterator end() const ETL_NOEXCEPT
Returns a const iterator to the end of the array.
Definition array.h:772
etl::array< T, 0 >::size
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:848
etl::array< T, 0 >::crbegin
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:804
etl::array< T, 0 >::at
ETL_NODISCARD ETL_CONSTEXPR14 const_reference at(size_t) const ETL_NOEXCEPT
Definition array.h:660
etl::array< T, 0 >::swap
ETL_CONSTEXPR14 void swap(array &) ETL_NOEXCEPT
Definition array.h:877
etl::array::erase_at
iterator erase_at(size_t position)
Definition array.h:484
etl::array< T, 0 >::back
ETL_NODISCARD ETL_CONSTEXPR const_reference back() const
Returns a const reference to the last element.
Definition array.h:712
etl::array::erase
iterator erase(const_iterator first, const_iterator last, parameter_t value)
Definition array.h:586
etl::array::erase
iterator erase(const_iterator position, parameter_t value)
Definition array.h:553
etl::array< T, 0 >::insert
iterator insert(const_iterator, TIterator, const TIterator) ETL_NOEXCEPT
Definition array.h:948
etl::array< T, 0 >::erase
iterator erase(const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1012
etl::array< T, 0 >::data
ETL_NODISCARD ETL_CONSTEXPR14 pointer data() ETL_NOEXCEPT
Returns a pointer to the first element of the internal buffer.
Definition array.h:720
etl::array< T, 0 >::cbegin
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:756
etl::array< T, 0 >::erase
iterator erase(const_iterator, const_iterator) ETL_NOEXCEPT
Definition array.h:990
etl::array::end
ETL_NODISCARD ETL_CONSTEXPR14 iterator end() ETL_NOEXCEPT
Returns an iterator to the end of the array.
Definition array.h:248
etl::array::insert
iterator insert(const_iterator position, parameter_t value)
Definition array.h:423
etl::array::crend
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:312
etl::array< T, 0 >::begin
ETL_NODISCARD ETL_CONSTEXPR const_iterator begin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:748
etl::array::empty
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:324
etl::array< T, 0 >::erase_at
iterator erase_at(size_t, parameter_t) ETL_NOEXCEPT
Definition array.h:1001
etl::array::data
ETL_NODISCARD ETL_CONSTEXPR const_pointer data() const ETL_NOEXCEPT
Returns a const pointer to the first element of the internal buffer.
Definition array.h:212
etl::array::size
ETL_NODISCARD ETL_CONSTEXPR size_t size() const ETL_NOEXCEPT
Returns the size of the array.
Definition array.h:332
etl::array::at
ETL_NODISCARD ETL_CONSTEXPR14 reference at(size_t i) ETL_NOEXCEPT_EXPR(ETL_NOT_USING_EXCEPTIONS)
Definition array.h:114
etl::array::swap
ETL_CONSTEXPR14 void swap(array &other) ETL_NOEXCEPT_FROM(ETL_OR_STD
Definition array.h:362
etl::array::insert
iterator insert(const_iterator position, TIterator first, const TIterator last)
Definition array.h:456
etl::array::assign
iterator assign(TIterator first, const TIterator last)
Definition array.h:381
etl::array< T, 0 >::rbegin
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rbegin() const ETL_NOEXCEPT
Returns a const reverse iterator to the reverse beginning of the array.
Definition array.h:796
etl::array< T, 0 >::front
ETL_NODISCARD ETL_CONSTEXPR14 reference front() ETL_NOEXCEPT
Returns a reference to the first element.
Definition array.h:688
etl::array::cbegin
ETL_NODISCARD ETL_CONSTEXPR const_iterator cbegin() const ETL_NOEXCEPT
Returns a const iterator to the beginning of the array.
Definition array.h:240
etl::array::erase
iterator erase(const_iterator position)
Definition array.h:496
etl::array< T, 0 >::back
ETL_NODISCARD ETL_CONSTEXPR14 reference back() ETL_NOEXCEPT
Returns a reference to the last element.
Definition array.h:704
etl::array::assign
iterator assign(TIterator first, const TIterator last, parameter_t value)
Definition array.h:395
etl::array< T, 0 >::erase
iterator erase(const_iterator, const_iterator, parameter_t) ETL_NOEXCEPT
Definition array.h:1035
etl::array< T, 0 >::rend
ETL_NODISCARD ETL_CONSTEXPR14 reverse_iterator rend() ETL_NOEXCEPT
Returns a reverse iterator to the end of the array.
Definition array.h:812
etl::array::erase_at
iterator erase_at(size_t position, parameter_t value)
Definition array.h:540
etl::array::front
ETL_NODISCARD ETL_CONSTEXPR const_reference front() const ETL_NOEXCEPT
Returns a const reference to the first element.
Definition array.h:174
etl::array::insert_at
iterator insert_at(size_t position, TIterator first, const TIterator last)
Definition array.h:442
etl::array::rend
ETL_NODISCARD ETL_CONSTEXPR const_reverse_iterator rend() const ETL_NOEXCEPT
Returns a const reverse iterator to the end of the array.
Definition array.h:304
etl::array< T, 0 >::empty
ETL_NODISCARD ETL_CONSTEXPR bool empty() const ETL_NOEXCEPT
Returns true if the array size is zero.
Definition array.h:840
etl::array::max_size
ETL_NODISCARD ETL_CONSTEXPR size_t max_size() const ETL_NOEXCEPT
Returns the maximum possible size of the array.
Definition array.h:340
etl::array
Definition array.h:85
etl::array_out_of_range
Definition array.h:70
ETL_ASSERT
#define ETL_ASSERT(b, e)
Definition error_handler.h:511
etl::exception::exception
ETL_EXCEPTION_CONSTEXPR exception(string_type reason_, string_type, numeric_type)
Constructor.
Definition exception.h:81
type
iterator.h
etl
Definition absolute.h:40
etl::swap
ETL_CONSTEXPR14 void swap(etl::typed_storage_ext< T > &lhs, etl::typed_storage_ext< T > &rhs) ETL_NOEXCEPT
Swap two etl::typed_storage_ext.
Definition alignment.h:856
etl::operator==
ETL_CONSTEXPR14 bool operator==(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1078
etl::operator>
bool operator>(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1130
etl::operator>=
bool operator>=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1144
etl::operator!=
ETL_CONSTEXPR14 bool operator!=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1090
etl::get
T & get(array< T, Size > &a)
Definition array.h:1158
etl::cend
TContainer::const_iterator cend(const TContainer &container)
Definition iterator.h:1186
etl::operator<
bool operator<(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1103
etl::operator<=
bool operator<=(const etl::array< T, SIZE > &lhs, const etl::array< T, SIZE > &rhs)
Definition array.h:1117
parameter_type.h
platform.h
etl::parameter_type::type
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:46
type_traits.h