From cb7ee61b33d4b531ae4cdfd90cdcf99dc28495be Mon Sep 17 00:00:00 2001 From: John Wellbelove Date: Tue, 14 Dec 2021 15:56:40 +0000 Subject: [PATCH] Disable span TContainer constructor for arrays --- include/etl/span.h | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/include/etl/span.h b/include/etl/span.h index b41c6bb5..412755b7 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -45,6 +45,15 @@ SOFTWARE. #if ETL_CPP11_SUPPORTED && ETL_USING_STL #include + #include + + #define ETL_BEGIN(x) std::begin(x) + #define ETL_END(x) std::end(x) +#else + #include "iterator.h" + + #define ETL_BEGIN(x) etl::begin(x) + #define ETL_END(x) etl::end(x) #endif namespace etl @@ -104,37 +113,14 @@ namespace etl } #endif -#if ETL_CPP11_SUPPORTED - //************************************************************************* - /// Construct from a container or other type that supports - /// data() and size() member functions. - //************************************************************************* - template ::value, int>::type> - ETL_CONSTEXPR span(TContainer& a) ETL_NOEXCEPT - : mbegin(a.data()) - , mend(a.data() + a.size()) - { - } - - //************************************************************************* - /// Construct from a container or other type that supports - /// data() and size() member functions. - //************************************************************************* - template ::value, int>::type> - ETL_CONSTEXPR span(const TContainer& a) ETL_NOEXCEPT - : mbegin(a.data()) - , mend(a.data() + a.size()) - { - } -#else //************************************************************************* /// Construct from a container or other type that supports /// data() and size() member functions. //************************************************************************* template ETL_CONSTEXPR span(TContainer& a) ETL_NOEXCEPT - : mbegin(a.data()) - , mend(a.data() + a.size()) + : mbegin(etl::addressof(*ETL_BEGIN(a))) + , mend(etl::addressof(*ETL_END(a))) { } @@ -144,11 +130,10 @@ namespace etl //************************************************************************* template ETL_CONSTEXPR span(const TContainer& a) ETL_NOEXCEPT - : mbegin(a.data()) - , mend(a.data() + a.size()) + : mbegin(etl::addressof(*ETL_BEGIN(a))) + , mend(etl::addressof(*ETL_END(a))) { } -#endif //************************************************************************* /// Construct from iterators