Suppose I have a std::vector
of std::pair
s, then I can using c++20 constrained algorithm's projection facility to sort elements according to sub-object:
std::vector<std::pair<int, std::string>> v;
// sort by std::string
ranges::sort(v, {}, &std::pair<int, std::string>::second);
but how to do nested projection like this?
// sort by std::string::size
ranges::sort(v, {}, &std::pair<int, std::string>::second::size);