Title
Domain of ranges::cmeow doesn't match ranges::meow
Status
nad
Section
[range.access]
Submitter
Hewill Kang

Created on 2024-12-17.00:00:00 last changed 2 days ago

Messages

Date: 2025-02-15.00:00:00

[ 2025-02-07; Reflector poll: NAD ]

"We don't need to support `ranges::cbegin` on non-ranges."

"Seems to be very similar to LWG 3913 which LWG closed as NAD."

Date: 2024-12-17.00:00:00

`ranges::begin/rbegin/data` can be used on non-ranges as long as the object has a `begin/rbegin/data` member, this is also true for their const versions before C++23.

However, in C++23 the const version always applied possibly-const-range to the object, which no longer worked for non-ranges due to this function requiring `input_range`, which seems to be a breaking change (demo):

#include <ranges>

struct NotRange {
        int* begin();
  const int* begin() const;
        int* rbegin();
  const int* rbegin() const;
        int* data();
  const int* data() const;
};

int main() {
  NotRange r;

  (void) std::ranges::begin(r);
  (void) std::ranges::rbegin(r);
  (void) std::ranges::data(r);

  // The following works in C++20, fails in C++23
  (void) std::ranges::cbegin(r);
  (void) std::ranges::crbegin(r);
  (void) std::ranges::cdata(r);
}
History
Date User Action Args
2025-02-07 22:17:50adminsetmessages: + msg14606
2025-02-07 22:17:50adminsetstatus: new -> nad
2024-12-17 00:00:00admincreate