16.3.8. copy_backward, merge, unique and reverse

Figure 16.8 demonstrates algorithms copy_backward, merge, unique and reverse.

 1   // Fig. 16.8: fig16_08.cpp 2   // Algorithms copy_backward, merge, unique and reverse. 3   #include <iostream> 4   #include <algorithm> // algorithm definitions 5   #include <array> // array class-template definition 6   #include <iterator> // ostream_iterator 7   using namespace std; 8  9   int main()10   {11      const size_t SIZE = 5;12      array< int, SIZE > a1 = { 1, 3, 5, 7, 9 };13      array< int, SIZE > a2 = { 2, 4, 5, 7, 9 };14      ostream_iterator< int > output( cout, " " );15 16      cout << "array a1 contains: ";17      copy( a1.cbegin(), a1.cend(), output ); // display ...

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.