Otherwise, size(t) converted to its decayed type, if ranges::disable_sized_range<std::remove_cv_t<T>> is false, and the converted expression is valid and has an integer-like type, where the overload resolution is performed with the following candidates:
void size(auto&) = delete;
void size(const auto&) = delete;
1
class Test {
friend size_t size(/*const*/ Test&) {
return 0;
}
};
int main() {
std::ranges::size(Test{});
// no matching function error when adding the `const` qualifier
}
https://godbolt.org/z/79e5vrKrT
Generally, size
method doesn't require to modify the range, like what std::size
does.
Why is there such a constraint of std::ranges::size
? (Seems it's only performed for non-member version.)