Does the STD library provide any function that allows me to find intersection of two std::hash_set?
I tried using std::set_intersection
but I get assertion error with Expression: sequence not ordered
, is there any work around this?
#include <hash_set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <string>
int main()
{
std::hash_set<std::string> h1;
h1.insert("NoMainDraw");
h1.insert("NoLight");
h1.insert("Random");
std::hash_set<std::string> h2;
h2.insert("NoLight");
std::vector<std::string> groupDifference;
std::set_intersection(h1.cbegin(), h1.cend(),
h2.cbegin(), h2.cend(),
std::back_inserter(groupDifference));
for(const std::string& i : groupDifference)
{
std::cout << i << std::endl;
}
}