Skip to content

Instantly share code, notes, and snippets.

@danlark1
Last active Apr 15, 2022
Embed
What would you like to do?
struct Data {
bool has_property;
// ...
};
std::vector<Data> data(FillData());
/*
Reorders the elements in the range [first, last) in such a way
that all elements for which the predicate p returns true precede
the elements for which predicate p returns false. Relative order
of the elements is not preserved.
*/
std::partition(data.begin(), data.end(), [](const Data& other) {
// Negation, so that all with property go to the right.
return !other.has_property;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment