[ox/std] Add overflow checking to SpanIterator
All checks were successful
Build / build (push) Successful in 2m36s

This commit is contained in:
Gary Talent 2024-11-19 01:09:48 -06:00
parent df44fe235b
commit 114f5c6685

View File

@ -8,6 +8,7 @@
#pragma once
#include "error.hpp"
#include "math.hpp"
#if !__has_include(<iterator>)
@ -129,14 +130,17 @@ struct SpanIterator {
}
constexpr PtrType operator->() const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
return &m_t[m_offset];
}
constexpr RefType operator*() const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, m_offset < m_max, "SpanIterator access overflow");
return m_t[m_offset];
}
constexpr RefType operator[](std::size_t s) const noexcept {
ox::primitiveAssert(__FILE__, __LINE__, s < m_max, "SpanIterator access overflow");
return m_t[s];
}