Illustrate set_union : set_union « STL Algorithms Merge « C++ Tutorial






#include <iostream>
#include <cassert>
#include <algorithm>
#include <vector>
using namespace std;

int main()
{
  bool result;

  string s("abcde");
  string s2("aeiou");

  vector<char> vector1(s.begin(), s.end());
  vector<char> vector2(s2.begin(), s2.end());

  vector<char> setUnion;
  set_union(vector1.begin(), vector1.end(),vector2.begin(), vector2.end(),back_inserter(setUnion));

  for(int i=0;i<setUnion.size();i++){
    cout << setUnion[i];
  }

  return 0;
}
abcdeiou








28.7.set_union
28.7.1.Illustrate set_union
28.7.2.Determine elements that are in either or both sets
28.7.3.unite the ranges by using set_union()