diff --git a/include/etl/span.h b/include/etl/span.h index 698b8f11..dcc7d22a 100644 --- a/include/etl/span.h +++ b/include/etl/span.h @@ -947,22 +947,25 @@ namespace etl #endif //************************************************************************* - /// Obtains a view to the object representation of the elements of the span s. + /// Obtains a view to the byte representation of the elements of the span s. //************************************************************************* - - template - auto as_bytes(span s) ETL_NOEXCEPT + template + span + as_bytes(span s) ETL_NOEXCEPT { - return span {reinterpret_cast(s.data()), s.size_bytes()}; + return span(reinterpret_cast(s.data()), s.size_bytes()); } - template - auto as_writable_bytes(span s) ETL_NOEXCEPT + //************************************************************************* + /// Obtains a view to the byte representation of the elements of the span s. + //************************************************************************* + template + span + as_writable_bytes(span s) ETL_NOEXCEPT { - ETL_STATIC_ASSERT(not etl::is_const::value, "span must be of non-const type"); - return span {reinterpret_cast(s.data()), s.size_bytes()}; + ETL_STATIC_ASSERT(!etl::is_const::value, "span must be of non-const type"); + return span(reinterpret_cast(s.data()), s.size_bytes()); } - } #endif diff --git a/test/test_span_dynamic_extent.cpp b/test/test_span_dynamic_extent.cpp index 17ac913a..2cd46b68 100644 --- a/test/test_span_dynamic_extent.cpp +++ b/test/test_span_dynamic_extent.cpp @@ -1128,13 +1128,13 @@ namespace //************************************************************************* TEST(test_convert_span_any_to_span_byte) { - /* mutable */ float data[2]{3.141592f, 2.71828f }; + float data[2]{3.141592f, 2.71828f }; - auto const const_bytes = etl::as_bytes(etl::span{data}); + auto const const_bytes = etl::as_bytes(etl::span{data}); auto const writable_bytes = etl::as_writable_bytes(etl::span{data}); - CHECK_TRUE(const_bytes.size() == sizeof(data)); - CHECK_TRUE(writable_bytes.size() == sizeof(data)); + CHECK_EQUAL(const_bytes.size(), sizeof(data)); + CHECK_EQUAL(writable_bytes.size(), sizeof(data)); }