[ox/std] Add missing + and += operators to Span
All checks were successful
Build / build (push) Successful in 2m38s

This commit is contained in:
Gary Talent 2024-11-27 00:17:37 -06:00
parent 27f4703a9a
commit 3308b4dd72

View File

@ -116,6 +116,7 @@ class SpanView {
} }
constexpr SpanView operator+=(size_t i) noexcept { constexpr SpanView operator+=(size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
m_items += i; m_items += i;
m_size -= i; m_size -= i;
return *this; return *this;
@ -143,7 +144,7 @@ class Span {
private: private:
T *m_items{}; T *m_items{};
const std::size_t m_size{}; std::size_t m_size{};
public: public:
using value_type = T; using value_type = T;
@ -243,6 +244,18 @@ class Span {
return m_items[i]; return m_items[i];
} }
constexpr Span operator+(size_t i) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
return {m_items + i, m_size - i};
}
constexpr Span operator+=(size_t i) noexcept {
ox::primitiveAssert(__FILE__, __LINE__, i < size(), "Span access overflow");
m_items += i;
m_size -= i;
return *this;
}
[[nodiscard]] [[nodiscard]]
constexpr auto data() const noexcept { constexpr auto data() const noexcept {
return m_items; return m_items;