So I got this code:
#include <vector>
#include <algorithm>
bool isEven(int x) {
return x % 2 == 0;
}
int main() {
std::vector<int> vec = {1,7,3,10,9,6};
std::stable_partition(vec.begin(), vec.end(), isEven);
}
Now I didn't understand what was the concrete difference between stable_partition and partition.
So I looked in my book and it said that:
stable_partition maintains the relative order of elements in each partition
But I don't understand, what is the relative order of the elements?
Does it mean that the elements that don't match the partition predicate stay in the same order? if yes, how can they be changed in std::partition?
Thanks in advance.