Search code examples
c++setset-intersection

print out data in the non-intersection for set <string> A, set<string>B


If I have two sets of data

set<string> A;
set<string> B;

use set_intersection I am able to obtain the data in the intersection part for the two sets.

How do I print out the data in the non-intersection part for the set A and set B, respectively?


Solution

  • Use std::set_difference or std::set_symmetric_difference, depending on your needs.

    (I'm too tired/lazy to write an example, but hopefully it should be obvious once you've read the above links!)