From bb4d31747aedb4c3fb21faff02bf15be79381d62 Mon Sep 17 00:00:00 2001 From: Patrick Wuttke Date: Sat, 16 Dec 2023 10:25:58 +0100 Subject: [PATCH] Added function to convert StrideSpan to regular span, if possible. --- source/mijin/container/stride_span.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/source/mijin/container/stride_span.hpp b/source/mijin/container/stride_span.hpp index 87770ca..6ee5435 100644 --- a/source/mijin/container/stride_span.hpp +++ b/source/mijin/container/stride_span.hpp @@ -119,6 +119,7 @@ public: constexpr operator bool() const noexcept { return !empty(); } constexpr bool operator!() const noexcept { return empty(); } + explicit operator std::span() const noexcept; reference operator[](size_type index); const_reference operator[](size_type index) const; @@ -138,6 +139,13 @@ public: // public functions // +template +StrideSpan::operator std::span() const noexcept +{ + MIJIN_ASSERT(strideBytes_ == sizeof(T), "Can't convert to regular span if stride isn't exactly size of type."); + return {&*begin_, &*end_}; +} + template StrideSpanIterator& StrideSpanIterator::operator+=(difference_type diff) {