[Libreoffice-commits] core.git: include/o3tl

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Mon Mar 18 18:18:42 UTC 2019


 include/o3tl/span.hxx |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 6ef8420fdbf8dff16de13147c5ab833bc5e01121
Author:     Stephan Bergmann <sbergman at redhat.com>
AuthorDate: Mon Mar 18 16:26:04 2019 +0100
Commit:     Stephan Bergmann <sbergman at redhat.com>
CommitDate: Mon Mar 18 19:18:17 2019 +0100

    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 at redhat.com>

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];
     }
 


More information about the Libreoffice-commits mailing list