16.3.10. Set Operations

Figure 16.10 demonstrates algorithms includes, set_difference, set_intersection, set_symmetric_difference and set_union for manipulating sets of sorted values.

 1   // Fig. 16.10: fig16_10.cpp 2   // Algorithms includes, set_difference, set_intersection, 3   // set_symmetric_difference and set_union. 4   #include <iostream> 5   #include <array> 6   #include <algorithm> // algorithm definitions 7   #include <iterator> // ostream_iterator 8   using namespace std; 9 10   int main()11   {12      const size_t SIZE1 = 10, SIZE2 = 5, SIZE3 = 20;13      array< int, SIZE1 > a1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };14      array< int, SIZE2 > a2 = { 4, 5, 6, 7, 8 };15      array< int, SIZE2 > a3 = { ...

Get C++11 for Programmers, Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.