Sometimes it is quite useful to group/partition the objects based on value of one of their member functions(either getter or some computation).
Do C++20 ranges enable something like
std::vector<Person> {{.Age=23, .Name = "Alice"}, {.Age=25, .Name = "Bob"}, {.Age=23, .Name = "Chad"}};
// group by .Age and put into std::map
std::map<int/*Age is int*/, std::vector<Person>> AgeToPerson = ...;
// 23 -> Person{23,Alice}, Person{23,Chad}
// 25 -> Person{25,Bob}
Note 1: there is this old question where accepted answer is to just use raw for loop
Note 2: range-v3 has this confusing group_by algorithm that seems useless for my task:
Given a source range and a binary predicate, return a range of ranges where each range contains contiguous elements from the source range such that the following condition holds: for each element in the range apart from the first, when that element and the first element are passed to the binary predicate, the result is true. In essence, views::group_by groups contiguous elements together with a binary predicate.