|
| template<std::size_t I, typename T, std::size_t N> |
| constexpr auto | dsa::get (Array< T, N > &array) noexcept -> T & |
| | Provide access to Ith element of an array.
|
| template<std::size_t I, typename T, std::size_t N> |
| constexpr auto | dsa::get (const Array< T, N > &array) noexcept -> const T & |
| | Provide access to Ith element of an array.
|
| template<std::size_t I, typename T, std::size_t N> |
| constexpr auto | dsa::get (Array< T, N > &&array) noexcept -> T && |
| | Provide access to Ith element of an array.
|
| template<std::size_t I, typename T, std::size_t N> |
| constexpr auto | dsa::get (const Array< T, N > &&array) noexcept -> const T && |
| | Provide access to Ith element of an array.
|
| template<typename T, std::size_t N> |
| void | dsa::swap (Array< T, N > &lhs, Array< T, N > &rhs) noexcept(noexcept(lhs.swap(rhs))) |
| | Exchanges content of two Array containers.
|
template<typename T, std::size_t N>
requires (!std::is_array_v<T>) |
| constexpr auto | dsa::to_array (T(&array)[N]) -> Array< std::remove_cv_t< T >, N > |
| | Creates Array from one dimensional C-style array using copy semantics.
|
template<typename T, std::size_t N>
requires (!std::is_array_v<T> && !std::is_const_v<T>) |
| constexpr auto | dsa::to_array (T(&&array)[N]) -> Array< std::remove_cv_t< T >, N > |
| | Creates Array from one dimensional C-style array using move semantics.
|
| template<typename T, std::size_t N> |
| auto | dsa::operator<< (std::ostream &out, const Array< T, N > &array) -> std::ostream & |
| | Overloads operator to print all elements of Array.
|
| template<typename T, std::size_t N> |
| constexpr auto | dsa::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.
|
| template<typename T, std::size_t N> |
| constexpr auto | dsa::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.
|
This file contains implementation of Array class.
- Author
- Michal Zygmunt
- Copyright
- Copyright (c) 2025 Michal Zygmunt This project is distributed under the MIT License. See accompanying LICENSE.txt file or obtain copy at https://opensource.org/license/mit
Definition in file array.h.
template<std::size_t I, typename T, std::size_t N>
| auto dsa::get |
( |
Array< T, N > && | array | ) |
-> T&&
|
|
nodiscardconstexprnoexcept |
Provide access to Ith element of an array.
Intentionally not moving entire parameter array. This overload of get<I>(dsa::Array&&) returns an rvalue reference to an element, matching the behaviour of std::get<I>(std::array&&) in C++ standard library. Only the selected element is moved from std::move(array[I]), not the whole array.
- Template Parameters
-
| I | index of element in container |
| T | data type stored in container |
| N | number of elements in container |
- Parameters
-
| [in] | array | container to extract element from |
- Returns
- T&& reference to Ith element of array container
Definition at line 485 of file array.h.
486 {
487 static_assert(I < N, "Index out of range in dsa::Array::get");
488 return std::move(array[I]);
489 }
template<typename T, std::size_t N>
| auto dsa::operator<=> |
( |
const Array< T, N > & | lhs, |
|
|
const Array< T, N > & | rhs ) -> std::compare_three_way_result_t<T>
|
|
nodiscardconstexprnoexcept |
The relational operator compares two Array objects.
Depending on type T, function returns one of following objects: std::strong_ordering::less / equal / greater std::weak_ordering::less / equivalent / greater std::partial_ordering::less / equivalent / greater / unordered It is best to compare results with 0 to determine if lhs is <, >, or == to rhs
- Parameters
-
| [in] | lhs | input container |
| [in] | rhs | input container |
- Returns
- three way comparison result type
Definition at line 625 of file array.h.
627 {
628 auto lhs_iter = lhs.
cbegin();
629 auto rhs_iter = rhs.
cbegin();
630
631 for (size_t i = 0; i < N; i++)
632 {
633 auto cmp = *lhs_iter <=> *rhs_iter;
634 if (cmp != 0)
635 {
636 return cmp;
637 }
638
639 lhs_iter++;
640 rhs_iter++;
641 }
642
643 return std::compare_three_way_result_t<T>::equivalent;
644 }
constexpr auto cbegin() const noexcept -> const_iterator
Returns const_iterator to first element.