This follows on from D115312, making all our CPOs follow the same pattern. In the process I found and fixed several conformance bugs (and probably fixed several more without finding them):
auto a = std::ranges::cbegin(std::string_view("x")); // should be OK auto b = std::ranges::cend(std::string_view("x")); // should be OK struct Foo { int size() &; }; int c = std::ranges::size(Foo()); // should be OK struct Incomplete; static_assert(not std::ranges::sized_range<Foo[]>); // should be OK
I'm aware that the tests for all of these CPOs are bad, but I have no immediate plans to refactor them. I have added the "obviously" missing coverage for cbegin and cend, and added/corrected regression tests for the bugs mentioned above. I've also added test/libcxx/ tests for our diagnostic quality, which now is very good IMO.
If this looks good, the next step would be for me to implement the missing CPOs — cdata, rbegin, rend, crbegin, crend — along these same lines. I propose to split access.h into begin.h (begin/cbegin) and end.h (end/cend); introduce rbegin.h (rbegin/crbegin) and rend.h (rend/crend); and add cdata to the existing data.h.
Here __go is constrained with requires __class_or_enum<...>, and has a dependent return type involving ADL end. I expect this to not be ADL-proof for suitably evil inputs, because dependent-return-type-SFINAE stuff happens before constraint satisfaction (AIUI, and/or at least on Clang it seemed to).
...Yep, here's the dynamite. https://godbolt.org/z/j453na433
This case fails both before and after D115607. Here's the failure mode after:
Since this one fails before and after, it's not a regression per se. However, it's also easy to fix using enable_if_t, as I've just proved to myself locally, so I might as well upload the fix. :)
Actually the part depicted here is also a Clang bug: https://github.com/llvm/llvm-project/issues/52643