2#include "gaia/config/config.h"
9#include "gaia/core/iterator.h"
10#include "gaia/core/utility.h"
11#include "gaia/mem/data_layout_policy.h"
16 namespace sarr_detail {
27 template <
typename T, sarr_detail::
size_type N>
78 GAIA_CONSTEXPR_DTOR
~sarr() =
default;
84 template <
typename InputIt>
86 const auto count = (
size_type)core::distance(first, last);
88 if constexpr (std::is_pointer_v<InputIt>) {
90 operator[](
i) = first[
i];
91 }
else if constexpr (std::is_same_v<typename InputIt::iterator_category, core::random_access_iterator_tag>) {
93 operator[](
i) = *(first[
i]);
96 for (
auto it = first;
it != last; ++
it)
97 operator[](
i++) = *
it;
105 constexpr sarr(
const sarr&) =
default;
121 GAIA_ASSERT(core::addressof(
other) !=
this);
133 GAIA_ASSERT(core::addressof(
other) !=
this);
141 GAIA_CLANG_WARNING_PUSH()
143 GAIA_CLANG_WARNING_DISABLE("-
Wcast-align")
160 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_type pos)
noexcept {
168 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_type pos)
const noexcept {
173 GAIA_CLANG_WARNING_POP()
300 if (!(
operator[](
i) ==
other[
i]))
315 template <
typename T, uint32_t N, uint32_t... I>
316 constexpr sarr<std::remove_cv_t<T>, N> to_array_impl(T (&a)[N], std::index_sequence<I...> ) {
327 template <
typename T, u
int32_t N>
328 constexpr sarr<std::remove_cv_t<T>, N> to_array(T (&a)[N]) {
329 return detail::to_array_impl(a, std::make_index_sequence<N>{});
335 template <
typename T,
typename... U>
336 sarr(T, U...) -> sarr<T, 1 + (uint32_t)
sizeof...(U)>;
342 template <
typename T, cnt::sarr_detail::
size_type N>
343 struct fixed_capacity<cnt::sarr<T, N>>: std::integral_constant<uint32_t, (uint32_t)N> {};
349 template <
typename T, u
int32_t N>
350 struct tuple_size<gaia::cnt::sarr<T, N>>: std::integral_constant<uint32_t, N> {};
352 template <
size_t I,
typename T, u
int32_t N>
353 struct tuple_element<I, gaia::cnt::sarr<T, N>> {
Array of elements of type.
Definition darray_ext_impl.h:31
GAIA_NODISCARD auto begin() noexcept
Returns an iterator to the first element.
Definition darray_ext_impl.h:613
GAIA_NODISCARD auto end() noexcept
Returns an iterator one past the last element.
Definition darray_ext_impl.h:649
darr_ext_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition darray_ext_impl.h:50
darr_ext_detail::difference_type difference_type
Type used for iterator differences.
Definition darray_ext_impl.h:48
Fixed-size stack array with AoS storage. Interface compatiblity with std::array where it matters.
Definition sarray_impl.h:28
GAIA_NODISCARD constexpr decltype(auto) back() noexcept
Accesses the last element.
Definition sarray_impl.h:213
GAIA_NODISCARD constexpr auto rend() const noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:285
constexpr sarr(std::initializer_list< T > il)
Constructs a container from an initializer list.
Definition sarray_impl.h:103
constexpr sarr & operator=(const sarr &other)
Copy-assigns the container.
Definition sarray_impl.h:120
GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) noexcept
Accesses an element without bounds checking in optimized builds.
Definition sarray_impl.h:160
constexpr sarr(InputIt first, InputIt last) noexcept
Constructs a container from an iterator range.
Definition sarray_impl.h:85
GAIA_NODISCARD constexpr pointer data() noexcept
Returns a pointer to the element storage.
Definition sarray_impl.h:147
GAIA_NODISCARD constexpr auto end() noexcept
Returns an iterator one past the last element.
Definition sarray_impl.h:261
GAIA_NODISCARD constexpr auto rbegin() noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_impl.h:243
sarr_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition sarray_impl.h:47
GAIA_NODISCARD constexpr bool operator==(const sarr &other) const
Compares two containers element by element.
Definition sarray_impl.h:298
core::reverse_iterator< iterator, difference_type > reverse_iterator
Mutable reverse random-access iterator type.
Definition sarray_impl.h:54
T m_data[N]
Inline storage backing the container elements.
Definition sarray_impl.h:66
GAIA_NODISCARD constexpr auto crend() const noexcept
Returns the read-only reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:291
GAIA_NODISCARD constexpr bool operator!=(const sarr &other) const
Checks whether two containers differ.
Definition sarray_impl.h:308
GAIA_NODISCARD constexpr auto rbegin() const noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_impl.h:249
T * pointer
Mutable element pointer type.
Definition sarray_impl.h:39
GAIA_NODISCARD constexpr auto cbegin() const noexcept
Returns a read-only iterator to the first element.
Definition sarray_impl.h:237
const_pointer const_iterator
Read-only random-access iterator type.
Definition sarray_impl.h:52
core::reverse_iterator< const_iterator, difference_type > const_reverse_iterator
Read-only reverse random-access iterator type.
Definition sarray_impl.h:56
const T * const_pointer
Read-only element pointer type.
Definition sarray_impl.h:41
GAIA_NODISCARD constexpr auto end() const noexcept
Returns an iterator one past the last element.
Definition sarray_impl.h:267
GAIA_NODISCARD constexpr auto crbegin() const noexcept
Returns a read-only reverse traversal iterator to the last element.
Definition sarray_impl.h:255
GAIA_NODISCARD constexpr decltype(auto) front() noexcept
Accesses the first element.
Definition sarray_impl.h:201
GAIA_NODISCARD constexpr auto cend() const noexcept
Returns a read-only iterator one past the last element.
Definition sarray_impl.h:273
GAIA_NODISCARD constexpr auto begin() noexcept
Returns an iterator to the first element.
Definition sarray_impl.h:225
static constexpr size_t value_size
Size of one element in bytes.
Definition sarray_impl.h:61
GAIA_NODISCARD constexpr auto rend() noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:279
sarr_detail::difference_type difference_type
Type used for iterator differences.
Definition sarray_impl.h:45
GAIA_NODISCARD constexpr size_type capacity() const noexcept
Returns the number of elements that fit without reallocation.
Definition sarray_impl.h:189
static constexpr size_type extent
Fixed capacity of the container.
Definition sarray_impl.h:63
GAIA_NODISCARD constexpr decltype(auto) back() const noexcept
Accesses the last element.
Definition sarray_impl.h:219
GAIA_NODISCARD constexpr size_type size() const noexcept
Returns the number of elements.
Definition sarray_impl.h:177
GAIA_NODISCARD constexpr size_type max_size() const noexcept
Returns the maximum number of elements supported by this container.
Definition sarray_impl.h:195
GAIA_NODISCARD constexpr const_pointer data() const noexcept
Returns a pointer to the element storage.
Definition sarray_impl.h:153
GAIA_NODISCARD constexpr bool empty() const noexcept
Checks whether the container has no elements.
Definition sarray_impl.h:183
GAIA_NODISCARD constexpr decltype(auto) front() const noexcept
Accesses the first element.
Definition sarray_impl.h:207
constexpr sarr & operator=(sarr &&other) noexcept
Move-assigns the container.
Definition sarray_impl.h:132
GAIA_NODISCARD constexpr auto begin() const noexcept
Returns an iterator to the first element.
Definition sarray_impl.h:231
pointer iterator
Mutable random-access iterator type.
Definition sarray_impl.h:50
Random-access iterator that traverses an underlying iterator in reverse. The stored iterator denotes ...
Definition iterator.h:24
Compile-time capacity of a container that can never grow. Zero for containers that can....
Definition utility.h:44
View policy for accessing and storing data in the AoS way. Good for random access and when accessing ...
Definition data_layout_policy.h:160