Standard C++ Library Class Reference
 OutputIterator result, Compare comp);
Description
The set_intersection algorithm constructs a sorted intersection of elements from the two ranges.
It returns the end of the constructed range. When it finds an element present in both ranges,
set_intersection always copies the element from the first range into result. This means that the
result of set_intersection is guaranteed to be stable. The result of set_intersection is undefined
if the result range overlaps with either of the original ranges.
set_intersection assumes that the ranges are sorted using the default comparision operator less
than (<), unless an alternative comparison operator (comp) is provided.
Complexity
At most ((last1 - first1) + (last2 - first2)) * 2 -1 comparisons are performed.
Example
//
// set_intr.cpp
//
 #include <algorithm>
 #include <set>
 #include <iostream.h>
 int main()
 {
 //Initialize some sets
 int a1[10] = {1,3,5,7,9,11};
 int a3[4] = {3,5,7,8};
 set<int, less<int> > odd(a1, a1+6),
 result, small(a3,a3+4);
 //Create an insert_iterator for result
 insert_iterator<set<int, less<int> > > 
 res_ins(result, result.begin());
 //Demonstrate set_intersection
 cout << "The result of:" << endl << "{";
 copy(small.begin(),small.end(),
 ostream_iterator<int>(cout," "));
 cout << "} intersection {";
 copy(odd.begin(),odd.end(),
 ostream_iterator<int>(cout," "));
 cout << "} =" << endl << "{";
 set_intersection(small.begin(), small.end(),
 odd.begin(), odd.end(), res_ins);










