Bounds checking.
Details
Details
- Reviewers
jdoerrie EricWF miscco ldionne - Group Reviewers
Restricted Project - Commits
- rG9eff07a746a9: [libc++] Add assert to check bounds in `constexpr string_view::operator[]`
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
I wanted to cry at the use of a comma operator, but all the other member functions do the same...
We might want to directly use __size rather than size() here to avoid the function call in DEBUG mode
Comment Actions
Thanks, everyone. Please commit it as "Chris Palmer <palmer@google.com>".
I suspect size() is always inlined, but I can change it to __size if you like. Other code, such as at, uses size().
Comment Actions
Late LGTM.
We discussed this over in https://reviews.llvm.org/D70343. IIUC this is required because libc++'s string_view is available in all dialects, and C++11 only allows you to have a single return statement in a constexpr function.