Open stephanlachnit opened 9 months ago
Given that SizeTypes can be signed, it should also check for indices[r] < 0.
Given that SizeTypes can be signed, it should also check for indices[r] < 0.
Thanks for this comment! Is this true for std::span
as well? At least in libstdc++
, they do not check this:
In span
, I believe it's always just std::size_t
, but mdspan
has the size type as a template parameter for the extent and can be signed.
In
span
, I believe it's always juststd::size_t
, butmdspan
has the size type as a template parameter for the extent and can be signed.
Ah right, thanks for pointing this out!
Edit: updated the pull request
Closes #300
Possible implementation for ::at element access to mdspan with boundary checks. The boundary check is implemented with a for loop, as I did not see any other way to achieve this. The error message is inspired by the
std::span::at
error message from libstdc++ (https://github.com/gcc-mirror/gcc/commit/1fa85dcf656e2f2c7e483c9ed3c2680bf7db6858).Note that this does not implement ::at element access to mdarray.