etl
927bb3cf - Make span std compliant (#317)

Commit
3 years ago
Make span std compliant (#317) * add missing overloads for span::first + span::last The C++20 standard defines additional overloads for first and last: template< std::size_t Count > constexpr std::span<element_type, Count> first() const; constexpr std::span<element_type, std::dynamic_extent> first( size_type Count ) const; template< std::size_t Count > constexpr std::span<element_type, Count> last() const; constexpr std::span<element_type, std::dynamic_extent> last( size_type Count ) const; etl implements only the first (= template) variants so far. To be able to compile valid C++20 code the missing overload should be added. * remove explicit specifier for span conversion operator The C++20 standard allows to assign a span of non-const elements to a span of const elements. Example: std::span<const int> cintspan; std::span<int> intspan; cintspan = intspan; This is enabled in the STL by using an explicit specifier with a constant expression for one of the conversion constructors: template< class R > explicit(extent != std::dynamic_extent) constexpr span( R&& r ); The explicit specifier together with a constant expression is a C++20 feature and therefore can't be used within etl. To be able to compile valid C++20 code which uses the conversion on assignment, the explicit specifier has to be removed. * remove explicit specifier for span conversion operator The C++20 standard allows to assign an array of elements directly (without explicitly using a conversion constructor). Example: const int data = { 1, 2, 3 }; std::span<const int> cintspan; cintspan = data; To be able to compile valid C++20 code which uses the conversion on assignment, the explicit specifier of the array-conversion constructor has to be removed.
Author
Parents
Loading