Removing duplicates for both values
Comment by @T.C.: 

Don't merge them; sort them separately and then use std::set_difference:

#include &lt;algorithm&gt;
#include &lt;vector&gt;
#include &lt;iostream&gt;
template &lt;typename T&gt;
void print(T&amp; c)
{
 for(auto &amp; element : c)
  std::cout &lt;&lt; element &lt;&lt; " ";

 std::cout &lt;&lt; "\n";
}

int main()
{
 std::vector&lt;int&gt; vec {1,2,3,4,6,7,8};
 std::vector&lt;int&gt; vec4 {3,4,5,6};
 std::sort(vec.begin(), vec.end());
 std::sort(vec4.begin(), vec4.end());
std::set_difference(vec.begin(), vec.end(), vec4.begin(), vec4.end(), std::inserter(vec5, vec5.begin()));
 print(vec5);
}



Input: {1,2,3,4,6,7,8} and {3,4,5,6}
Output wanted: 1,2,5,7,8
Output real: 1,2,7,8


You cannot use std::set_difference because of the hashes used as comparison criteria. The Hash Distribution of new hashes is not sortable in a way that new items will be the last ones, which is a requirement for std::set_difference.