Reputation: 67211
I Have two sets of strings.
set<string> A;
set<string> B;
I will insert some elements into both the sets and some of the elements that I insert into them are common elements.
I can basically get the elements
using
std::set_difference
I can also get the common elements in both the sets by
using
std::set_intersection
How can I get the elements which and present only in A and only in B and put them in a different set?
Total idea is creating a set which will not have the common elements but all the elements in both the sets.
In mathematical language:
(A(UNION)B)-(A(intersection)B)
Upvotes: 1
Views: 126
Reputation: 409166
How about std::set_symmetric_difference
? It seems to fit what you want.
Upvotes: 2