32 using const_reference =
const T&;
34 using const_pointer =
const T*;
37 using size_type = sarr_detail::size_type;
39 using iterator = pointer;
40 using const_iterator = const_pointer;
43 static constexpr size_t value_size =
sizeof(T);
44 static constexpr size_type extent =
N;
48 constexpr sarr()
noexcept =
default;
54 for (
auto i = (size_type)0;
i < extent; ++
i)
58 GAIA_CONSTEXPR_DTOR
~sarr() =
default;
60 template <
typename InputIt>
62 const auto count = (size_type)core::distance(first, last);
64 if constexpr (std::is_pointer_v<InputIt>) {
65 for (size_type
i = 0;
i < count; ++
i)
66 operator[](
i) = first[
i];
67 }
else if constexpr (std::is_same_v<typename InputIt::iterator_category, core::random_access_iterator_tag>) {
68 for (size_type i = 0; i < count; ++i)
69 operator[](i) = *(first[i]);
72 for (
auto it = first; it != last; ++it)
73 operator[](++i) = *it;
77 constexpr sarr(std::initializer_list<T> il): sarr(il.begin(), il.end()) {}
79 constexpr sarr(
const sarr& other) =
default;
81 constexpr sarr(sarr&& other)
noexcept =
default;
83 sarr& operator=(std::initializer_list<T> il) {
84 *
this = sarr(il.begin(), il.end());
88 constexpr sarr& operator=(
const sarr& other) {
89 GAIA_ASSERT(core::addressof(other) !=
this);
91 for (size_type i = 0; i < extent; ++i)
92 m_data[i] = other.m_data[i];
97 constexpr sarr& operator=(sarr&& other)
noexcept {
98 GAIA_ASSERT(core::addressof(other) !=
this);
100 for (size_type i = 0; i < extent; ++i)
101 m_data[i] = GAIA_MOV(other.m_data[i]);
106 GAIA_CLANG_WARNING_PUSH()
108 GAIA_CLANG_WARNING_DISABLE("-Wcast-align")
110 GAIA_NODISCARD constexpr pointer data() noexcept {
114 GAIA_NODISCARD
constexpr const_pointer data() const noexcept {
118 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](size_type pos)
noexcept {
119 GAIA_ASSERT(pos < size());
123 GAIA_NODISCARD
constexpr decltype(
auto)
operator[](size_type pos)
const noexcept {
124 GAIA_ASSERT(pos < size());
128 GAIA_CLANG_WARNING_POP()
130 GAIA_NODISCARD constexpr size_type size() const noexcept {
134 GAIA_NODISCARD
constexpr bool empty() const noexcept {
138 GAIA_NODISCARD
constexpr size_type capacity() const noexcept {
142 GAIA_NODISCARD
constexpr size_type max_size() const noexcept {
146 GAIA_NODISCARD
constexpr decltype(
auto) front() noexcept {
147 return (reference)*begin();
150 GAIA_NODISCARD
constexpr decltype(
auto) front() const noexcept {
151 return (const_reference)*begin();
154 GAIA_NODISCARD
constexpr decltype(
auto) back() noexcept {
155 return (reference) operator[](N - 1);
158 GAIA_NODISCARD
constexpr decltype(
auto) back() const noexcept {
159 return (const_reference) operator[](N - 1);
162 GAIA_NODISCARD
constexpr auto begin() noexcept {
163 return iterator(&m_data[0]);
166 GAIA_NODISCARD
constexpr auto begin() const noexcept {
167 return const_iterator(&m_data[0]);
170 GAIA_NODISCARD
constexpr auto cbegin() const noexcept {
171 return const_iterator(&m_data[0]);
174 GAIA_NODISCARD
constexpr auto rbegin() noexcept {
175 return iterator((pointer)&back());
178 GAIA_NODISCARD
constexpr auto rbegin() const noexcept {
179 return const_iterator((const_pointer)&back());
182 GAIA_NODISCARD
constexpr auto crbegin() const noexcept {
183 return const_iterator((const_pointer)&back());
186 GAIA_NODISCARD
constexpr auto end() noexcept {
187 return iterator(&m_data[0] + size());
190 GAIA_NODISCARD
constexpr auto end() const noexcept {
191 return const_iterator(&m_data[0] + size());
194 GAIA_NODISCARD
constexpr auto cend() const noexcept {
195 return const_iterator(&m_data[0] + size());
198 GAIA_NODISCARD
constexpr auto rend() noexcept {
199 return iterator(&m_data[0] - 1);
202 GAIA_NODISCARD
constexpr auto rend() const noexcept {
203 return const_iterator(&m_data[0] - 1);
206 GAIA_NODISCARD
constexpr auto crend() const noexcept {
207 return const_iterator(&m_data[0] - 1);
210 GAIA_NODISCARD
constexpr bool operator==(
const sarr& other)
const {
211 for (size_type i = 0; i < N; ++i)
212 if (!(
operator[](i) == other[i]))
217 GAIA_NODISCARD
constexpr bool operator!=(
const sarr& other)
const {
218 return !operator==(other);