From 34029b4b7848ed68c6978eca40d2ebf37ee05e79 Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Mon, 4 Sep 2023 09:00:51 +0100 Subject: [PATCH] Added conversion operators to std::span --- include/etl/span.h | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/include/etl/span.h b/include/etl/span.h index 18e672f4b..a0004c418 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -45,6 +45,10 @@ SOFTWARE. #include "private/dynamic_extent.h" +#if ETL_USING_CPP20 && ETL_USING_STL + #include +#endif + ///\defgroup span span ///\ingroup containers @@ -357,6 +361,16 @@ namespace etl : etl::span(pbegin + offset, pbegin + offset + count); } +#if ETL_USING_CPP20 && ETL_USING_STL + //************************************************************************* + /// Conversion operator to std::span + //************************************************************************* + ETL_NODISCARD ETL_CONSTEXPR operator etl::span() + { + return std::span(pbegin, Extent); + } +#endif + private: pointer pbegin; @@ -366,7 +380,7 @@ namespace etl /// Span - Dynamic Extent //*************************************************************************** template - class span + class span { public: @@ -679,6 +693,16 @@ namespace etl : etl::span(pbegin + offset, pbegin + offset + count); } +#if ETL_USING_CPP20 && ETL_USING_STL + //************************************************************************* + /// Conversion operator to std::span + //************************************************************************* + ETL_NODISCARD ETL_CONSTEXPR operator etl::span() + { + return std::span(pbegin, etl::dynamic_extent); + } +#endif + private: pointer pbegin;