P3052R2 — view_interface::at()
SG9SG23
This paper provides the `at()` method to `ranges::view_interface` to provide a safe access method for the view class. Revision history R2 Rename the feature-test macro based on LEWG feedback. R1 Added wording for freestanding. R0 Initial revision. Discussion Currently, the committee adopted [P2821](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/p2821r4.html) in C++26, which adds a missing `at()` to `std::span` to consistent its API with other containers as well as `std::string_view`. Given that the two standard views `span` and `string_view` now have the `at()` method, The author thinks it's time to extend this further to generic views in `<ranges>`, which will bring: Consistency. [P1739](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2020/p1739r4.html) brings interaction between range adaptors and `span`/`string_view`, suggesting that it makes sense to maintain API consistency. Users do not need to worry about missing functionality when converting from the first two to view such as `subrange`. Table — Standard range types and access APIs Element access operator[] at front back data string/array/vector ✅ ✅ ✅ ✅ ✅ string_view/span ✅ ✅ ✅ ✅ ✅ ranges::*meow*_view ✅ ❌ ✅ ✅