-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[libc++] The rest of P2278R4 (cdata, as_const_view, span changes) #102301
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
Conversation
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LWG3811 and LWG3850 are completed here and thus the entries should be updated:
| "`LWG3811 <https://wg21.link/LWG3811>`__","``views::as_const`` on ``ref_view<T>`` should return ``ref_view<const T>``","February 2023","","","|ranges|" |
| "`LWG3850 <https://wg21.link/LWG3850>`__","``views::as_const`` on ``empty_view<T>`` should return ``empty_view<const T>``","February 2023","","","|ranges|" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Papers: [P2278R4][], [P2836R1][]
PR: [LLVM-PR-99915][]
Implements:
- `basic_const_iterator`, `const_iterator`, and `const_sentinel`
- The const accessors - `ranges::{cbegin,cend,crbegin,crend}`
- Add `cbegin` and `cend` member functions to `view_interface`
- The changes from [P2836R1][].
Still to be done:
- `ranges::as_const_view`, `ranges::views::as_const`
- `cdata`
- The changes to `span`
Drive-by:
- Fix some includes that would have been circular.
[P2278R4]: https://wg21.link/p2278r4
[P2836R1]: https://wg21.link/p2836r1
[LLVM-PR-99915]: llvm#99915
drive-by: remove the `__ranges/data.h` header and merge it with `__ranges/access.h` (for `ranges::data`), or `__ranges/const_access.h` (for `ranges::cdata`). I felt comfortable doing this as every use of `__ranges/access.h` included either `__ranges/data.h` itself, or `__ranges/concepts.h` which itself included `__ranges/data.h`.
Note that we have an interesting extension in `span` to support volatile types - this breaks `std::const_iterator`. I've made the choice to, when `span`'s element type is `volatile`, set `const_iterator` and `const_reverse_iterator` to `void`, and disable `cbegin` and friends.
includes testing
I wonder if it would be a good idea to do something more similar to what MSVC does here, with `_Choice` stuff.
3ee5363 to
659a4fb
Compare
|
Closing as this will be merged into the original PR. |
This PR depends on, and is committed on top of, LLVM-PR-99915.
This PR completes the rest of P2278R4 that was not done in the original PR:
Actual changes (excluding those from LLVM-PR-99915): diff 99915.
cdataspan(includes some interesting choices sinceconst_iteratorcannot supportvolatileelement types)as_const_viewandviews::as_const__cpp_lib_ranges_as_constfeature macro