summaryrefslogtreecommitdiff
path: root/include/o3tl
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2021-10-28 09:27:29 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-10-29 12:38:51 +0200
commit894b4911ffb96ff667fdeb3aec7922316ab7230a (patch)
tree3942ed8088c058b70bb79984b186c5156284abf4 /include/o3tl
parent5b0ae3b59cd2cccfb72d991657366eb2a69bff49 (diff)
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. Change-Id: I5088a139593c27bf9cbe5d843ab4b0048ac6d508 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124330 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/o3tl')
-rw-r--r--include/o3tl/span.hxx5
1 files changed, 5 insertions, 0 deletions
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_; }