I've searched all over, but I can't find a built-in way to perform boolean operations between unordered_sets in c++. I've read about set_intersection, but that only works on ordered sets.
This is incredibly easy in something like Python:
a = set([1, 2, 3, 4])
b = set([2, 4])
>>> a.difference(b)
set([1, 3])
>>> a.intersection(b)
set([2, 4])
>>> a.union(b)
set([1, 2, 3, 4])
I have trouble believing that between C++11 and boost, there's no clean way of doing this without writing your own functions.
Am I missing something? Is there a reason something like this doesn't exist already?
EDIT: I've read this post, but it only describes a way to write your own intersect/difference/union functions. I'm looking for something built into stl or boost.
EDIT: It may be easier to describe this way...
std::unordered_set<int> whole({1, 2, 3, 4});
std::unordered_set<int> even({2, 4});
// Why doesn't something like the following exist?
std::unordered_set<int> odd = whole.difference(even);
// Result would contain {1, 3}.
This is something that I would expect to be so frequently used that I have trouble believing it isn't built-in somewhere (or at least in boost).