Skip to content

Commit

Permalink
Added conversion operators to std::span
Browse files Browse the repository at this point in the history
  • Loading branch information
John Wellbelove committed Sep 4, 2023
1 parent d517847 commit 34029b4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion include/etl/span.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ SOFTWARE.

#include "private/dynamic_extent.h"

#if ETL_USING_CPP20 && ETL_USING_STL
#include <span>
#endif

///\defgroup span span
///\ingroup containers

Expand Down Expand Up @@ -357,6 +361,16 @@ namespace etl
: etl::span<element_type, etl::dynamic_extent>(pbegin + offset, pbegin + offset + count);
}

#if ETL_USING_CPP20 && ETL_USING_STL
//*************************************************************************
/// Conversion operator to std::span
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR operator etl::span<element_type, Extent>()
{
return std::span<element_type, Extent>(pbegin, Extent);
}
#endif

private:

pointer pbegin;
Expand All @@ -366,7 +380,7 @@ namespace etl
/// Span - Dynamic Extent
//***************************************************************************
template <typename T>
class span<T, etl::dynamic_extent>
class span<T, etl::dynamic_extent>
{
public:

Expand Down Expand Up @@ -679,6 +693,16 @@ namespace etl
: etl::span<element_type, etl::dynamic_extent>(pbegin + offset, pbegin + offset + count);
}

#if ETL_USING_CPP20 && ETL_USING_STL
//*************************************************************************
/// Conversion operator to std::span
//*************************************************************************
ETL_NODISCARD ETL_CONSTEXPR operator etl::span<element_type, etl::dynamic_extent>()
{
return std::span<element_type, etl::dynamic_extent>(pbegin, etl::dynamic_extent);
}
#endif

private:

pointer pbegin;
Expand Down

0 comments on commit 34029b4

Please sign in to comment.