Add array container
Closed this issue · 0 comments
apcountryman commented
Add array container.
-
libraries/microlibrary/ANY/ANY/include/microlibrary/array.h
/libraries/microlibrary/ANY/ANY/source/microlibrary/array.cc
(add)- Add
::microlibrary::Array
template class - Add
::microlibrary::array_size
type property - Add
::microlibrary::array_size_v
type property
- Add
-
libraries/microlibrary/ANY/ANY/CMakeLists.txt
(update) -
docs/index.md
(update) -
docs/containers/array.md
(add) - The
::microlibrary::Array
template class should have the following template parameters:-
typename T
: The array element type. -
std::size_t N
: The number of elements in the array.
-
- The
::microlibrary::Array
template class should have the following member types:-
using Value = T;
: The array element type -
using Size = std::size_t;
: The number of elements in the array -
using Position = std::size_t;
: An array element position -
using Reference = Value &;
: A reference to an array element -
using Const_Reference = Value const &;
: A reference to a const array element -
using Pointer = Value *;
: A pointer to an array element -
using Const_Pointer = Value const *;
: A pointer to a const array element -
using Iterator = Pointer;
: An array iterator -
using Const_Iterator = Const_Pointer;
: A const array iterator -
using Reverse_Iterator = std::reverse_iterator<Iterator>;
: An array reverse iterator -
using Const_Reverse_Iterator = std::reverse_iterator<Const_Iterator>;
: A const array reverse iterator
-
- The
::microlibrary::Array
template class should support the following operations:-
constexpr auto operator[]( Position position ) noexcept -> Reference;
: Access the element at the specified position in the array -
constexpr auto operator[]( Position position ) const noexcept -> Const_Reference;
: Access the element at the specified position in the array -
constexpr auto at( Position position ) noexcept -> Reference;
: Access the element at the specified position in the array -
constexpr auto at( Position position ) const noexcept -> Const_Reference;
: Access the element at the specified position in the array -
constexpr auto front() noexcept -> Reference;
: Access the first element of the array -
constexpr auto front() const noexcept -> Const_Reference;
: Access the first element of the array -
constexpr auto back() noexcept -> Reference;
: Access the last element of the array -
constexpr auto back() const noexcept -> Const_Reference;
: Access the last element of the array -
constexpr auto data() noexcept -> Pointer;
: Access the underlying array -
constexpr auto data() const noexcept -> Const_Pointer;
: Access the underlying array -
constexpr auto begin() noexcept -> Iterator;
: Get an iterator to the first element of the array -
constexpr auto begin() const noexcept -> Const_Iterator;
: Get an iterator to the first element of the array -
constexpr auto cbegin() const noexcept -> Const_Iterator;
: Get an iterator to the first element of the array -
constexpr auto end() noexcept -> Iterator;
: Get an iterator to the element following the last element of the array -
constexpr auto end() const noexcept -> Const_Iterator;
: Get an iterator to the element following the last element of the array -
constexpr auto cend() const noexcept -> Const_Iterator;
: Get an iterator to the element following the last element of the array -
constexpr auto rbegin() noexcept -> Iterator;
: Get an iterator to the first element of the reversed array -
constexpr auto rbegin() const noexcept -> Const_Iterator;
: Get an iterator to the first element of the reversed array -
constexpr auto crbegin() const noexcept -> Const_Iterator;
: Get an iterator to the first element of the reversed array -
constexpr auto rend() noexcept -> Iterator;
: Get an iterator to the element following the last element of the reversed array -
constexpr auto rend() const noexcept -> Const_Iterator;
: Get an iterator to the element following the last element of the reversed array -
constexpr auto crend() const noexcept -> Const_Iterator;
: Get an iterator to the element following the last element of the reversed array -
[[nodiscard]] constexpr auto empty() const noexcept -> bool;
: Check if the array is empty -
constexpr auto size() const noexcept -> Size;
: Get the number of elements in the array -
template<typename T, std::size_t N> constexpr auto operator==( Array<T, N> const & lhs, Array<T, N> const & rhs ) noexcept -> bool;
(non-member) -
template<typename T, std::size_t N> constexpr auto operator!=( Array<T, N> const & lhs, Array<T, N> const & rhs ) noexcept -> bool;
(non-member)
-
- The
::microlibraary::array_size
and::microlibrary::array_size_v
type properties should have the following definition:
template<typename T>
struct array_size {
};
template<typename T>
inline constexpr auto array_size_v = array_size<T>::value;
template<typename T, std::size_t N>
struct array_size<Array<T, N>> : std::integral_constant<std::size_t, N> {
}'