++


set_union() - 2


set<string,less<string>,allocator> set1( str1, str1+4 );

set<string,less<string>,allocator> set2( str2, str2+3 );

 

cout << " #1:\n\t";

copy( set1.begin(), set1.end(), ofile ); cout << "\n\n";

cout << " #2:\n\t";

copy( set2.begin(), set2.end(), ofile ); cout << "\n\n";

 

set<string,less<string>,allocator> res;

set_union( set1.begin(), set1.end(),

set2.begin(), set2.end(),

inserter( res, res.begin() ));

 

cout << " set_union():\n\t";

copy( res.begin(), res.end(), ofile ); cout << "\n\n";

 

res.clear();

set_intersection( set1.begin(), set1.end(),

set2.begin(), set2.end(),

inserter( res, res.begin() ));

 

cout << " set_intersection():\n\t";

copy( res.begin(), res.end(), ofile ); cout << "\n\n";

 

res.clear();

set_difference( set1.begin(), set1.end(),

set2.begin(), set2.end(),

inserter( res, res.begin() ));

 

cout << " set_difference():\n\t";

copy( res.begin(), res.end(), ofile ); cout << "\n\n";

 

res.clear();

set_symmetric_difference( set1.begin(), set1.end(),

set2.begin(), set2.end(),

inserter( res, res.begin() ));

 

cout << " set_symmetric_difference():\n\t";

copy( res.begin(), res.end(), ofile ); cout << "\n\n";

}




- -  - -  - -