Fixed StrideSpan::size() for default-constructed spans and added empty check + operatators.
This commit is contained in:
parent
ce7a7b15c7
commit
4f7e8ae39f
@ -117,10 +117,14 @@ public:
|
|||||||
StrideSpan& operator=(const StrideSpan&) = default;
|
StrideSpan& operator=(const StrideSpan&) = default;
|
||||||
auto operator<=>(const StrideSpan&) const noexcept = default;
|
auto operator<=>(const StrideSpan&) const noexcept = default;
|
||||||
|
|
||||||
|
constexpr operator bool() const noexcept { return !empty(); }
|
||||||
|
constexpr bool operator!() const noexcept { return empty(); }
|
||||||
|
|
||||||
reference operator[](size_type index);
|
reference operator[](size_type index);
|
||||||
const_reference operator[](size_type index) const;
|
const_reference operator[](size_type index) const;
|
||||||
|
|
||||||
[[nodiscard]] constexpr size_type size() const noexcept { return bytediff(begin_, end_) / strideBytes_; }
|
[[nodiscard]] constexpr size_type size() const noexcept { return strideBytes_ == 0 ? 0 : bytediff(begin_, end_) / strideBytes_; }
|
||||||
|
[[nodiscard]] constexpr bool empty() const noexcept { return begin_ == end_; }
|
||||||
|
|
||||||
[[nodiscard]] iterator begin() { return StrideSpanIterator<T>(begin_, strideBytes_, begin_, end_); }
|
[[nodiscard]] iterator begin() { return StrideSpanIterator<T>(begin_, strideBytes_, begin_, end_); }
|
||||||
[[nodiscard]] const_iterator begin() const { return StrideSpanIterator<const T>(begin_, strideBytes_, begin_, end_); }
|
[[nodiscard]] const_iterator begin() const { return StrideSpanIterator<const T>(begin_, strideBytes_, begin_, end_); }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user