30 template<
typename T, std::
size_t N>
113 throw std::out_of_range(
"Pos argument outside of container range");
131 throw std::out_of_range(
"Pos argument outside of container range");
376 [[nodiscard]]
constexpr auto empty() const noexcept ->
bool
424 std::swap(
m_data, other.m_data);
446 template<std::
size_t I,
typename T, std::
size_t N>
449 static_assert(I < N,
"Index out of range in dsa::Array::get");
462 template<std::
size_t I,
typename T, std::
size_t N>
465 static_assert(I < N,
"Index out of range in dsa::Array::get");
483 template<std::
size_t I,
typename T, std::
size_t N>
487 static_assert(I < N,
"Index out of range in dsa::Array::get");
488 return std::move(array[I]);
500 template<std::
size_t I,
typename T, std::
size_t N>
501 [[nodiscard]]
constexpr auto get(
const Array<T, N>&& array)
noexcept ->
const T&&
503 static_assert(I < N,
"Index out of range in dsa::Array::get");
504 return std::move(array[I]);
515 template<
typename T, std::
size_t N>
528 template<
typename T, std::
size_t N>
529 requires(!std::is_array_v<T>)
535 return[&]<std::size_t... I>(std::index_sequence<I...>)
539 }(std::make_index_sequence<N>{});
549 template<
typename T, std::
size_t N>
550 requires(!std::is_array_v<T> && !std::is_const_v<T>)
556 return[&]<std::size_t... I>(std::index_sequence<I...>)
560 }(std::make_index_sequence<N>{});
571 template<
typename T, std::
size_t N>
574 for (
size_t i = 0; i < N; i++)
576 out << array[i] <<
' ';
590 template<
typename T, std::
size_t N>
592 noexcept(
noexcept(*lhs.begin() == *rhs.begin())) ->
bool
594 auto lhs_iter = lhs.cbegin();
595 auto rhs_iter = rhs.cbegin();
597 for (
size_t i = 0; i < N; i++)
599 if (*lhs_iter != *rhs_iter)
624 template<
typename T, std::
size_t N>
626 noexcept(
noexcept(*lhs.begin() == *rhs.begin())) -> std::compare_three_way_result_t<T>
628 auto lhs_iter = lhs.cbegin();
629 auto rhs_iter = rhs.cbegin();
631 for (
size_t i = 0; i < N; i++)
633 auto cmp = *lhs_iter <=> *rhs_iter;
643 return std::compare_three_way_result_t<T>::equivalent;
668 template<
typename T, std::
size_t N>
669 struct tuple_size <dsa::Array<T, N>> : std::integral_constant<std::size_t, N>
684 template<std::
size_t I,
typename T, std::
size_t N>
685 struct tuple_element<I, dsa::Array<T, N>>
714 template<
typename T, std::
size_t N>
715 inline constexpr bool enable_borrowed_range<dsa::Array<T, N>> =
true;
729 template<
typename T, std::
size_t N>
730 inline constexpr bool enable_view<dsa::Array<T, N>> =
true;
744 template<
typename T, std::
size_t N>
745 inline constexpr bool enable_view<const dsa::Array<T, N>> =
true;
constexpr auto operator==(const Array< T, N > &lhs, const Array< T, N > &rhs) noexcept(noexcept(*lhs.begin()== *rhs.begin())) -> bool
The relational operator compares two Array objects.
constexpr auto operator<=>(const Array< T, N > &lhs, const Array< T, N > &rhs) noexcept(noexcept(*lhs.begin()== *rhs.begin())) -> std::compare_three_way_result_t< T >
The relational operator compares two Array objects.
void swap(Array< T, N > &lhs, Array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs)))
Exchanges content of two Array containers.
auto operator<<(std::ostream &out, const Array< T, N > &array) -> std::ostream &
Overloads operator to print all elements of Array.
constexpr auto get(Array< T, N > &array) noexcept -> T &
Provide access to Ith element of an array.
constexpr auto to_array(T(&array)[N]) -> Array< std::remove_cv_t< T >, N >
Creates Array from one dimensional C-style array using copy semantics.
Implements Array class template for fixed size container.
constexpr auto operator[](size_type pos) const -> const_reference
Returns a const_reference to Array element at pos index. If pos is outside of container range,...
void fill(const value_type &value)
Assigns value to all elements of the container.
constexpr auto crbegin() const noexcept -> const_reverse_iterator
Returns const_reverse_iterator to the first element of reversed underlaying array structure.
constexpr auto front() -> reference
Returns reference to first Arary element.
constexpr auto begin() const noexcept -> const_iterator
Returns const_iterator to first element.
constexpr auto back() const -> const_reference
Returns const_reference to last Arary element.
std::reverse_iterator< iterator > reverse_iterator
Alias for reverse_iterator to data type used in class.
const value_type & const_reference
Alias for const reference to data type used in class.
constexpr auto max_size() const noexcept -> size_type
Returns maximum number of elements container can hold.
T value_type
Alias for data type used in class.
constexpr auto at(size_type pos) const -> const_reference
Returns a const_reference to Array element at pos index. If pos is outside of container range,...
constexpr auto size() const noexcept -> size_type
Returns number of elements in container.
std::reverse_iterator< const_iterator > const_reverse_iterator
Alias for const reverse_iterator to data type used in class.
constexpr auto rend() noexcept -> reverse_iterator
Returns reverse_iterator past the last element of reversed underlaying array structure.
constexpr auto rbegin() const noexcept -> const_reverse_iterator
Returns const_reverse_iterator to the first element of reversed underlaying array structure.
constexpr auto front() const -> const_reference
Returns const_reference to first Arary element.
constexpr auto cend() const noexcept -> const_iterator
Returns const_iterator past last element of underlaying array structure.
const value_type * const_iterator
Alias for const iterator to data type used in class.
constexpr auto end() const noexcept -> const_iterator
Returns const_iterator past last element of underlaying array structure.
value_type * pointer
Alias for pointer to data type used in class.
constexpr auto back() -> reference
Returns reference to last Arary element.
value_type * iterator
Alias for iterator to data type used in class.
constexpr auto crend() const noexcept -> const_reverse_iterator
Returns const_reverse_iterator past the last element of reversed underlaying array structure.
constexpr auto rend() const noexcept -> const_reverse_iterator
Returns const_reverse_iterator past the last element of reversed underlaying array structure.
constexpr auto end() noexcept -> iterator
Returns iterator past last element of underlaying array structure.
constexpr auto operator[](size_type pos) -> reference
Returns a reference to Array element at pos index. If pos is outside of container range,...
value_type & reference
Alias for reference to data type used in class.
constexpr auto rbegin() noexcept -> reverse_iterator
Returns reverse_iterator to the first element of reversed underlaying array structure.
constexpr auto data() const noexcept -> const_pointer
Returns const_pointer to underlying array container.
constexpr auto data() noexcept -> pointer
Returns pointer to underlying array container.
std::size_t size_type
Alias for size type used in class.
value_type m_data[N==0 ? 1 :N]
Underlaying fixed size array containing all elements Conditional size is used to handle zero sized ar...
std::ptrdiff_t difference_type
Alias for pointer difference type.
constexpr auto empty() const noexcept -> bool
Checks if container has elements.
constexpr auto at(size_type pos) -> reference
Returns a reference to Array element at pos index. If pos is outside of container range,...
constexpr auto begin() noexcept -> iterator
Returns iterator to first element.
constexpr void swap(Array< T, N > &other) noexcept(std::is_nothrow_swappable_v< T >)
Exchanges content of current container with other container.
constexpr auto cbegin() const noexcept -> const_iterator
Returns const_iterator to first element.
const value_type * const_pointer
Alias for const pointer to data type used in class.