Skip to content

Instantly share code, notes, and snippets.

@danlark1
Last active April 15, 2022 12:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danlark1/cc0b451fedd0646a1b4e5d235e8be2c4 to your computer and use it in GitHub Desktop.
Save danlark1/cc0b451fedd0646a1b4e5d235e8be2c4 to your computer and use it in GitHub Desktop.
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