add more span checks
This commit is contained in:
@ -13,8 +13,8 @@ namespace bse {
|
|||||||
using iterator = ContinuousIterator<T>;
|
using iterator = ContinuousIterator<T>;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
T* ptr;
|
T* const ptr;
|
||||||
std::size_t sz = N;
|
const std::size_t sz = N;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
span() = default;
|
span() = default;
|
||||||
@ -31,14 +31,14 @@ namespace bse {
|
|||||||
|
|
||||||
T* operator[](std::size_t i) {
|
T* operator[](std::size_t i) {
|
||||||
if constexpr (N != 0) {
|
if constexpr (N != 0) {
|
||||||
if (i >= N) { return nullptr; }
|
if (i < 0 || i >= N) { return nullptr; }
|
||||||
}
|
}
|
||||||
return &ptr[i];
|
return &ptr[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
const T* operator[](std::size_t i) const {
|
T* operator[](std::size_t i) const {
|
||||||
if constexpr (N != 0) {
|
if constexpr (N != 0) {
|
||||||
if (i >= N) { return nullptr; }
|
if (i < 0 || i >= N) { return nullptr; }
|
||||||
}
|
}
|
||||||
return &ptr[i];
|
return &ptr[i];
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user