Unfortunately, I believe that you are limited to a linear O(N)
solution, as all a union would be is a combination of the elements in both sets.
template
S union_sets(const S& s1, const S& s2)
{
S result = s1;
result.insert(s2.cbegin(), s2.cend());
return result;
}