diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2019-03-18 16:26:04 +0100 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2019-03-18 19:18:17 +0100 |
commit | 6ef8420fdbf8dff16de13147c5ab833bc5e01121 (patch) | |
tree | a63da7e0df3ace891ea5a50300a3ac4c7dcfd981 /include/o3tl/span.hxx | |
parent | a11a2d84b09f85d2020c47f3ce42cd9efbff818a (diff) |
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,
ece27693ba52417bc4b68045f5544a5cc43299dc "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: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'include/o3tl/span.hxx')
-rw-r--r-- | include/o3tl/span.hxx | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/include/o3tl/span.hxx b/include/o3tl/span.hxx index acb31bab728d..1618b86df897 100644 --- a/include/o3tl/span.hxx +++ b/include/o3tl/span.hxx @@ -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]; } |