-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access with bounds checking using ::at
#300
Comments
@stephanlachnit Thanks for the suggestion! : - ) Are you considering writing that paper? |
I think this is fine. There aren't really any additional concerns beyond the ones which would show up in span. So if span gets it mdspan also should. Was the proposal for span::at voted into C++26 in Kona? I didn't check. |
I have never written a C++ proposal and unfortunately would not be able to present in person at an ISO C++ standards meeting. I can try to write a paper draft, but I would probably need some help. Edit: I started drafting a proposal at https://github.com/stephanlachnit/mdspan-at
I'm not sure where to check, but according to cplusplus/papers#1501 (comment) yes. |
@mhoemmen @crtrott I decided to give the paper a shot anyway, please take a look at my draft with wording relative to N4964 at https://stephanlachnit.github.io/mdspan-at/. Would you like to be co-authors and present it to the C++ standards committee? |
I looked at the wording and I was wondering whether
is sufficient and you don't need to repeat the constraints. |
@stephanlachnit wrote:
Thank you for taking interest in this. I should have expressed myself better: My personal view is that I'd rather not spend time adding |
Given that OtherIndexTypes can be signed, shouldn't it also throw out_of_range if indices[i] < 0 for any indices[i] in indices? Or do you allow negative indexing? |
Note that a custom layout could do multidimensional bounds checking, and a custom accessor could do (1-D) bounds checking for any layout. |
In C++26,
std::span
will get a::at
member function. It's probably a good idea to do this for mdspan as well. The function signatures would be the same as inoperator[]
:Another neat advantage is that this does not require the multidimensional subscript operator, meaning that the signature is identical between in pre C++23 code.
Related discussion on std-proposals: https://lists.isocpp.org/std-proposals/2023/11/index.php#msg8301
The text was updated successfully, but these errors were encountered: