Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/utils/include/utils/containers.h
Original file line number Diff line number Diff line change
Expand Up @@ -526,11 +526,13 @@ std::vector<T> sorted_by(std::unordered_set<T> const &s, F const &f) {

template <typename T, typename F>
void inplace_sorted_by(std::vector<T> &v, F const &f) {
struct {
struct custom_comparator {
F const f;
custom_comparator(F const &f) : f(f) {};
bool operator()(T const &lhs, T const &rhs) { return f(lhs, rhs); }
} custom_comparator;
};

std::sort(v.begin(), v.end(), custom_comparator);
std::sort(v.begin(), v.end(), custom_comparator(f));
}

template <typename C, typename F>
Expand Down