Closed mike919192 closed 4 months ago
Review changes with SemanticDiff.
I also realized that the first and last functions also behave similarly, so I have also added the checks for those functions. I believe those are all the functions where static checks are possible.
std::array<int, 10> array {0};
//std::span std_span1 = std::span(array).first<15>(); //compile time error
//std::span std_span2 = std::span(array).last<15>(); //compile time error
etl::span etl_span1 = etl::span(array).first<15>(); //currently no compile time error
etl::span etl_span2 = etl::span(array).last<15>(); //currently no compile time error
I don't know if it makes sense to also add the static assert for the pre c++11 subspan function? I'll await @jwellbelove feedback.
The ETL_STATIC_ASSERT
will work for pre-C++11 as the macro defines a C++03 static assert implementation.
Thanks. I duplicated the static asserts for the pre c++11 subspan function. I should be finished with changes unless there are other issues.
Potential fix for issue #842
etl::span subspan function does not currently statically check extents. std::span does check this.
Code demonstration:
This PR should enable c++11 and newer to have compile error when the extent check fails.