C++ algorithm like python's 'groupby'
问题 Are there any C++ transformations which are similar to itertools.groupby()? Of course I could easily write my own, but I'd prefer to leverage the idiomatic behavior or compose one from the features provided by the STL or boost . #include <cstdlib> #include <map> #include <algorithm> #include <string> #include <vector> struct foo { int x; std::string y; float z; }; bool lt_by_x(const foo &a, const foo &b) { return a.x < b.x; } void list_by_x(const std::vector<foo> &foos, std::map<int, std: