include/o3tl/span.hxx |    5 +++++
 1 file changed, 5 insertions(+)

New commits:
commit f144f028f108e2f7a025f2befb3519ed43a04bc6
Author:     Noel Grandin <[email protected]>
AuthorDate: Thu Oct 28 09:27:29 2021 +0200
Commit:     Michael Stahl <[email protected]>
CommitDate: Thu Jan 9 18:54:38 2025 +0100

    pass DX array around using o3tl::span instead of pointer
    
    so we get bounds checking in debug mode
    
    Note that I cannot just pass around the std::vectors
    involved because there is a place in editeng which
    calls with a subset of a vector.
    
    [note: backport only contains the o3tl::span changes]
    
    Change-Id: I5088a139593c27bf9cbe5d843ab4b0048ac6d508
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124330
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <[email protected]>
    (cherry picked from commit 894b4911ffb96ff667fdeb3aec7922316ab7230a)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180009
    Tested-by: allotropia jenkins <[email protected]>
    Reviewed-by: Michael Stahl <[email protected]>

diff --git a/include/o3tl/span.hxx b/include/o3tl/span.hxx
index 8af8ba846b65..087d1f9d69c3 100644
--- a/include/o3tl/span.hxx
+++ b/include/o3tl/span.hxx
@@ -25,6 +25,7 @@ namespace o3tl { using std::span; }
 #include <cassert>
 #include <cstddef>
 #include <iterator>
+#include <type_traits>
 
 namespace o3tl {
 
@@ -57,6 +58,10 @@ public:
         assert(a != nullptr || len == 0);
     }
 
+    /** for assigning from span<T> to span<const T> */
+    constexpr span (const span<typename std::remove_const<T>::type>& other) 
noexcept
+        : data_(other.data()), size_(other.size()) {}
+
     constexpr bool empty() const noexcept { return size_ == 0; }
 
     constexpr iterator begin() const noexcept { return data_; }

Reply via email to