Kaydet (Commit) 6ef8420f authored tarafından Stephan Bergmann's avatar Stephan Bergmann

Adapt o3tl::span to updated C++2a std::span

...where index_type has changed from ptrdiff_t to size_t, see <https://
github.com/cplusplus/draft/commit/7f2493e2e2d34b42a6c12c8806e536d4feb3aee3>
"P1227R2 Signed ssize() functions, unsigned size() functions".  Ideally,
ece27693 "Adapt to C++2a std::span<>::index_type
being unsigned size_t" could be simplified now to use std::size_t, but there may
be build environments that include a C++2a <span> that hasn't been adapted to
P1227R2 yet.

Change-Id: I7bfc0da65d415ef06e94d95b5f62030aeb8b35f6
Reviewed-on: https://gerrit.libreoffice.org/69391
Tested-by: Jenkins
Reviewed-by: 's avatarStephan Bergmann <sbergman@redhat.com>
üst a11a2d84
......@@ -40,7 +40,7 @@ public:
using iterator = pointer;
using const_reverse_iterator = std::reverse_iterator<const_iterator>;
using reverse_iterator = std::reverse_iterator<iterator>;
using index_type = std::ptrdiff_t;
using index_type = std::size_t;
using difference_type = std::ptrdiff_t;
constexpr span() noexcept : data_(nullptr), size_(0) {}
......@@ -52,7 +52,7 @@ public:
: data_(a), size_(len)
{
// not terribly sure about this, might need to strengthen it
assert((a == nullptr && len == 0) || (a != nullptr && len >= 0));
assert(a != nullptr || len == 0);
}
constexpr bool empty() const noexcept { return size_ == 0; }
......@@ -75,7 +75,7 @@ public:
constexpr index_type size() const noexcept { return size_; }
constexpr reference operator [](index_type pos) const {
assert(0 <= pos && pos < size());
assert(pos < size());
return data_[pos];
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment