Ranges in C++20 are not very appetizing for many people who came from less-verbose languages like Python, because typing std::ranges::
is too verbose.
The proposals seem to have own rationales, but what I don't understand are constrained algorithms, consider std::sort
and std::ranges::sort
:
std::sort
: link
std::ranges::sort
: link
I don't really understand why we have to type like this
std::vector<int> v {3, 1, 4, 2, 6};
std::ranges::sort(v);
Oh, my... just why? Why we can't have std::sort(v);
? I can't find any overload resolution ambiguity between the range version of std::ranges::sort()
and all versions of std::sort()
. (I understand a version that takes an iterator pair, I hate the range version)
Do you know the reason behind this decision?