Suppose I have two sets of strings:
set<string> set1;
set<string> set2;
And I want to compute the union of set1 and set2 and store the result back
into set1, how can I do this?
I tried to use the set_union algorithm in the following way, but it didn't
work for me:
set<string>::it erator f1 = set1.begin();
set<string>::it erator f2 = set2.begin();
set<string>::it erator o1 = set1.begin();
set_union(f1, set1.end(), f2, set2.end(), o1);
Can somebody tell me what's wrong with this? Thanks a lot.
set<string> set1;
set<string> set2;
And I want to compute the union of set1 and set2 and store the result back
into set1, how can I do this?
I tried to use the set_union algorithm in the following way, but it didn't
work for me:
set<string>::it erator f1 = set1.begin();
set<string>::it erator f2 = set2.begin();
set<string>::it erator o1 = set1.begin();
set_union(f1, set1.end(), f2, set2.end(), o1);
Can somebody tell me what's wrong with this? Thanks a lot.
Comment