My Project
|
Provides a safe encapsulation for a C-style array, minicing the std::array APIs. This container is an aggregate type, but unlike a std::array, a bsl::array does not provide the T[n] syntax as this is nither Core Guideline compliant or compliant with AUTOSAR. Instead we provide at_if() versions which return a pointer to the element being requested. If the element does not exist, a nullptr is returned, providing a means to check for logic errors without the need for exceptions or failing fast which is not compliant with AUTOSAR. We also do not support N==0 type arrays and like other BSL classes, we do not support the member version of swap() and fill() as they are not compliant with AUTOSAR (due to the name reuse). User bsl::swap() and bsl::fill() instead. More...
#include <array.hpp>
Public Types | |
using | value_type = T |
alias for: T | |
using | size_type = bsl::uintmax |
alias for: bsl::uintmax | |
using | difference_type = bsl::uintmax |
alias for: bsl::uintmax | |
using | reference_type = T & |
alias for: T & | |
using | const_reference_type = T const & |
alias for: T const & | |
using | pointer_type = T * |
alias for: T * | |
using | const_pointer_type = T const * |
alias for: T const * | |
using | iterator_type = contiguous_iterator< T > |
alias for: contiguous_iterator<T> | |
using | const_iterator_type = contiguous_iterator< T const > |
alias for: contiguous_iterator<T const> | |
using | reverse_iterator_type = reverse_iterator< iterator_type > |
alias for: reverse_iterator<iterator> | |
using | const_reverse_iterator_type = reverse_iterator< const_iterator_type > |
alias for: reverse_iterator<const_iterator> | |
Public Member Functions | |
constexpr pointer_type | at_if (size_type const index) noexcept |
Returns a pointer to the instance of T stored at index "index". If the index is out of bounds, or the array is invalid, this function returns a nullptr. More... | |
constexpr const_pointer_type | at_if (size_type const index) const noexcept |
Returns a pointer to the instance of T stored at index "index". If the index is out of bounds, or the array is invalid, this function returns a nullptr. More... | |
constexpr reference_type | front () noexcept |
Returns a reference to the first element in the array. More... | |
constexpr const_reference_type | front () const noexcept |
Returns a reference to the first element in the array. More... | |
constexpr pointer_type | front_if () noexcept |
Returns a pointer to the first element in the array. More... | |
constexpr const_pointer_type | front_if () const noexcept |
Returns a pointer to the first element in the array. More... | |
constexpr reference_type | back () noexcept |
Returns a reference to the last element in the array. More... | |
constexpr const_reference_type | back () const noexcept |
Returns a reference to the last element in the array. More... | |
constexpr pointer_type | back_if () noexcept |
Returns a pointer to the last element in the array. More... | |
constexpr const_pointer_type | back_if () const noexcept |
Returns a pointer to the last element in the array. More... | |
constexpr pointer_type | data () noexcept |
Returns a pointer to the array being encapsulated. More... | |
constexpr const_pointer_type | data () const noexcept |
Returns a pointer to the array being encapsulated. More... | |
constexpr iterator_type | begin () noexcept |
Returns an iterator to the first element of the array. More... | |
constexpr const_iterator_type | begin () const noexcept |
Returns an iterator to the first element of the array. More... | |
constexpr const_iterator_type | cbegin () const noexcept |
Returns an iterator to the first element of the array. More... | |
constexpr iterator_type | iter (size_type const i) noexcept |
Returns an iterator to the element "i" in the array. More... | |
constexpr const_iterator_type | iter (size_type const i) const noexcept |
Returns an iterator to the element "i" in the array. More... | |
constexpr const_iterator_type | citer (size_type const i) const noexcept |
Returns an iterator to the element "i" in the array. More... | |
constexpr iterator_type | end () noexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned. More... | |
constexpr const_iterator_type | end () const noexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned. More... | |
constexpr const_iterator_type | cend () const noexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned. More... | |
constexpr reverse_iterator_type | rbegin () noexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | rbegin () const noexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | crbegin () const noexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr reverse_iterator_type | riter (size_type const i) noexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | riter (size_type const i) const noexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | criter (size_type const i) const noexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr reverse_iterator_type | rend () noexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | rend () const noexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
constexpr const_reverse_iterator_type | crend () const noexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation. More... | |
Static Public Member Functions | |
static constexpr bool | empty () noexcept |
Since arrays of size 0 are not allowed, always returns false. More... | |
static constexpr size_type | size () noexcept |
Returns the number of elements in the array being encapsulated. More... | |
static constexpr size_type | max_size () noexcept |
Returns the max number of elements the BSL supports. More... | |
static constexpr size_type | size_bytes () noexcept |
Returns size() * sizeof(T) More... | |
Public Attributes | |
T | m_data [N] |
stores the array being wrapped | |
Related Functions | |
(Note that these are not member functions.) | |
template<typename T , bsl::uintmax N> | |
constexpr bool | operator== (bsl::array< T, N > const &lhs, bsl::array< T, N > const &rhs) noexcept |
Returns true if two arrays contain the same contents. Returns false otherwise. More... | |
template<typename T , bsl::uintmax N> | |
constexpr bool | operator!= (bsl::array< T, N > const &lhs, bsl::array< T, N > const &rhs) noexcept |
Returns false if two arrays contain the same contents. Returns true otherwise. More... | |
Provides a safe encapsulation for a C-style array, minicing the std::array APIs. This container is an aggregate type, but unlike a std::array, a bsl::array does not provide the T[n] syntax as this is nither Core Guideline compliant or compliant with AUTOSAR. Instead we provide at_if() versions which return a pointer to the element being requested. If the element does not exist, a nullptr is returned, providing a means to check for logic errors without the need for exceptions or failing fast which is not compliant with AUTOSAR. We also do not support N==0 type arrays and like other BSL classes, we do not support the member version of swap() and fill() as they are not compliant with AUTOSAR (due to the name reuse). User bsl::swap() and bsl::fill() instead.
T | the type of element being encapsulated. |
N | the total number of elements in the array. Cannot be 0 |
|
inlinenoexcept |
Returns a pointer to the instance of T stored at index "index". If the index is out of bounds, or the array is invalid, this function returns a nullptr.
SUPPRESSION: PRQA 4024 - false positive
index | the index of the instance to return |
|
inlinenoexcept |
Returns a pointer to the instance of T stored at index "index". If the index is out of bounds, or the array is invalid, this function returns a nullptr.
index | the index of the instance to return |
|
inlinenoexcept |
Returns a reference to the first element in the array.
|
inlinenoexcept |
Returns a reference to the first element in the array.
|
inlinenoexcept |
Returns a pointer to the first element in the array.
|
inlinenoexcept |
Returns a pointer to the first element in the array.
|
inlinenoexcept |
Returns a reference to the last element in the array.
|
inlinenoexcept |
Returns a reference to the last element in the array.
|
inlinenoexcept |
Returns a pointer to the last element in the array.
|
inlinenoexcept |
Returns a pointer to the last element in the array.
|
inlinenoexcept |
Returns a pointer to the array being encapsulated.
|
inlinenoexcept |
Returns a pointer to the array being encapsulated.
|
inlinenoexcept |
Returns an iterator to the first element of the array.
|
inlinenoexcept |
Returns an iterator to the first element of the array.
|
inlinenoexcept |
Returns an iterator to the first element of the array.
|
inlinenoexcept |
Returns an iterator to the element "i" in the array.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns an iterator to the element "i" in the array.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns an iterator to the element "i" in the array.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned.
|
inlinenoexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned.
|
inlinenoexcept |
Returns an iterator to one past the last element of the array. If you attempt to access this iterator, a nullptr will always be returned.
|
inlinenoexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinenoexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinenoexcept |
Returns a reverse iterator to one past the last element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinenoexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns a reverse iterator element "i" in the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
i | the element in the array to return an iterator for. |
|
inlinenoexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinenoexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinenoexcept |
Returns a reverse iterator first element of the array. When accessing the iterator, the iterator will always return the element T[internal index - 1], providing access to the range [N - 1, 0) while internally storing the range [N, 1) with element 0 representing the end(). For more information, see the bsl::reverse_iterator documentation.
|
inlinestaticnoexcept |
Since arrays of size 0 are not allowed, always returns false.
|
inlinestaticnoexcept |
Returns the number of elements in the array being encapsulated.
|
inlinestaticnoexcept |
Returns the max number of elements the BSL supports.
|
inlinestaticnoexcept |
Returns size() * sizeof(T)
|
related |
Returns true if two arrays contain the same contents. Returns false otherwise.
T | the type of element being encapsulated. |
N | the total number of elements in the array. Cannot be 0 |
lhs | the left hand side of the operation |
rhs | the right hand side of the operation |
|
related |
Returns false if two arrays contain the same contents. Returns true otherwise.
T | the type of element being encapsulated. |
N | the total number of elements in the array. Cannot be 0 |
lhs | the left hand side of the operation |
rhs | the right hand side of the operation |