ETLCPP / etl

Embedded Template Library
https://www.etlcpp.com
MIT License
2.05k stars 372 forks source link

Fixed Extent etl::span shouldn't allow default constructor #825

Closed omar-droubi closed 2 months ago

omar-droubi commented 5 months ago

With recent ETL versions, it's allowed to to create a default Fixed Extent etl::span<T, S>.

This causes a problem because the member function size() returns "Extend" even though the data is nullptr. This different from old behavior were there two pointers "mbegin, mend" and the size was the difference.

Fixed Extent etl::span should be considered as a view to existing data.

Current std::span doesn't allow default construction, so it would make sense that etl does the same.

etl::span<uint8_t, 10> x; // compiles
std::cout << x.size() << std::endl; // prints 10 but x is nullptr
std::span<uint8_t, 10> x; //doesn't compile

Options:

jwellbelove commented 2 months ago

Fixed 20.38.11