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>
74 GAIA_CONSTEXPR_DTOR
~sarr() =
default;
80 template <
typename InputIt>
82 const auto count = (
size_type)core::distance(first, last);
84 if constexpr (std::is_pointer_v<InputIt>) {
86 operator[](
i) = first[
i];
87 }
else if constexpr (std::is_same_v<typename InputIt::iterator_category, core::random_access_iterator_tag>) {
89 operator[](
i) = *(first[
i]);
92 for (
auto it = first;
it != last; ++
it)
93 operator[](++
i) = *
it;
101 constexpr sarr(
const sarr&) =
default;
117 GAIA_ASSERT(core::addressof(other) !=
this);
129 GAIA_ASSERT(core::addressof(other) !=
this);
132 m_data[
i] = GAIA_MOV(other.m_data[
i]);
137 GAIA_CLANG_WARNING_PUSH()
139 GAIA_CLANG_WARNING_DISABLE("-
Wcast-align")
156 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_type pos)
noexcept {
164 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](
size_type pos)
const noexcept {
169 GAIA_CLANG_WARNING_POP()
296 if (!(
operator[](
i) == other[
i]))
311 template <
typename T, uint32_t N, uint32_t... I>
312 constexpr sarr<std::remove_cv_t<T>, N> to_array_impl(T (&a)[N], std::index_sequence<I...> ) {
323 template <
typename T, u
int32_t N>
324 constexpr sarr<std::remove_cv_t<T>, N> to_array(T (&a)[N]) {
325 return detail::to_array_impl(a, std::make_index_sequence<N>{});
331 template <
typename T,
typename... U>
332 sarr(T, U...) -> sarr<T, 1 + (uint32_t)
sizeof...(U)>;
339 template <
typename T, u
int32_t N>
340 struct tuple_size<gaia::cnt::sarr<T, N>>: std::integral_constant<uint32_t, N> {};
342 template <
size_t I,
typename T, u
int32_t N>
343 struct tuple_element<I, gaia::cnt::sarr<T, N>> {
Array with variable size of elements of type.
Definition darray_impl.h:27
darr_detail::size_type size_type
Unsigned type used for sizes and indices.
Definition darray_impl.h:44
GAIA_NODISCARD auto begin() noexcept
Returns an iterator to the first element.
Definition darray_impl.h:556
darr_detail::difference_type difference_type
Type used for iterator differences.
Definition darray_impl.h:42
GAIA_NODISCARD auto end() noexcept
Returns an iterator one past the last element.
Definition darray_impl.h:592
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:209
GAIA_NODISCARD constexpr auto rend() const noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:281
constexpr sarr(std::initializer_list< T > il)
Constructs a container from an initializer list.
Definition sarray_impl.h:99
constexpr sarr & operator=(const sarr &other)
Copy-assigns the container.
Definition sarray_impl.h:116
GAIA_NODISCARD constexpr decltype(auto) operator[](size_type pos) noexcept
Accesses an element without bounds checking in optimized builds.
Definition sarray_impl.h:156
constexpr sarr(InputIt first, InputIt last) noexcept
Constructs a container from an iterator range.
Definition sarray_impl.h:81
GAIA_NODISCARD constexpr pointer data() noexcept
Returns a pointer to the element storage.
Definition sarray_impl.h:143
GAIA_NODISCARD constexpr auto end() noexcept
Returns an iterator one past the last element.
Definition sarray_impl.h:257
GAIA_NODISCARD constexpr auto rbegin() noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_impl.h:239
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:294
T m_data[N]
Inline storage backing the container elements.
Definition sarray_impl.h:62
GAIA_NODISCARD constexpr auto crend() const noexcept
Returns the read-only reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:287
GAIA_NODISCARD constexpr bool operator!=(const sarr &other) const
Checks whether two containers differ.
Definition sarray_impl.h:304
GAIA_NODISCARD constexpr auto rbegin() const noexcept
Returns a reverse traversal iterator to the last element.
Definition sarray_impl.h:245
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:233
const_pointer const_iterator
Read-only random-access iterator type.
Definition sarray_impl.h:52
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:263
GAIA_NODISCARD constexpr auto crbegin() const noexcept
Returns a read-only reverse traversal iterator to the last element.
Definition sarray_impl.h:251
GAIA_NODISCARD constexpr decltype(auto) front() noexcept
Accesses the first element.
Definition sarray_impl.h:197
GAIA_NODISCARD constexpr auto cend() const noexcept
Returns a read-only iterator one past the last element.
Definition sarray_impl.h:269
GAIA_NODISCARD constexpr auto begin() noexcept
Returns an iterator to the first element.
Definition sarray_impl.h:221
static constexpr size_t value_size
Size of one element in bytes.
Definition sarray_impl.h:57
GAIA_NODISCARD constexpr auto rend() noexcept
Returns the reverse traversal sentinel preceding the first element.
Definition sarray_impl.h:275
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:185
static constexpr size_type extent
Fixed capacity of the container.
Definition sarray_impl.h:59
GAIA_NODISCARD constexpr decltype(auto) back() const noexcept
Accesses the last element.
Definition sarray_impl.h:215
GAIA_NODISCARD constexpr size_type size() const noexcept
Returns the number of elements.
Definition sarray_impl.h:173
GAIA_NODISCARD constexpr size_type max_size() const noexcept
Returns the maximum number of elements supported by this container.
Definition sarray_impl.h:191
GAIA_NODISCARD constexpr const_pointer data() const noexcept
Returns a pointer to the element storage.
Definition sarray_impl.h:149
GAIA_NODISCARD constexpr bool empty() const noexcept
Checks whether the container has no elements.
Definition sarray_impl.h:179
GAIA_NODISCARD constexpr decltype(auto) front() const noexcept
Accesses the first element.
Definition sarray_impl.h:203
constexpr sarr & operator=(sarr &&other) noexcept
Move-assigns the container.
Definition sarray_impl.h:128
GAIA_NODISCARD constexpr auto begin() const noexcept
Returns an iterator to the first element.
Definition sarray_impl.h:227
pointer iterator
Mutable random-access iterator type.
Definition sarray_impl.h:50
View policy for accessing and storing data in the AoS way. Good for random access and when accessing ...
Definition data_layout_policy.h:162