diff options
author | Luboš Luňák <l.lunak@collabora.com> | 2021-10-31 11:23:11 +0100 |
---|---|---|
committer | Luboš Luňák <l.lunak@collabora.com> | 2021-10-31 15:52:02 +0100 |
commit | b5e701d36ec16776e01597fd250dbde2e73fad3a (patch) | |
tree | c5f5fee0355dc6eca66dd4dcaca40a78e63dc6cf /include/o3tl/span.hxx | |
parent | d4b63c4562ec4c612df675502fd35c7c88bc432d (diff) |
add o3tl::span ctor from std::vector
Makes code simpler, and std::span can be constructed from std::vector
too.
Change-Id: Iae26b53c52148c19d9068a63126a7393d098d654
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124507
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Reviewed-by: Luboš Luňák <l.lunak@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'include/o3tl/span.hxx')
-rw-r--r-- | include/o3tl/span.hxx | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/include/o3tl/span.hxx b/include/o3tl/span.hxx index 087d1f9d69c3..cfe4c1ffa3a3 100644 --- a/include/o3tl/span.hxx +++ b/include/o3tl/span.hxx @@ -26,6 +26,7 @@ namespace o3tl { using std::span; } #include <cstddef> #include <iterator> #include <type_traits> +#include <vector> namespace o3tl { @@ -58,6 +59,10 @@ public: assert(a != nullptr || len == 0); } + template<typename T2> + constexpr span(const std::vector<T2>& vec) + : data_(vec.data()), size_(vec.size()) {} + /** 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()) {} |