16.3.3. remove, remove_if, remove_copy and remove_copy_if

Figure 16.3 demonstrates removing values from a sequence with algorithms remove, remove_if, remove_copy and remove_copy_if.

 1   // Fig. 16.3: fig16_03.cpp 2   // Algorithms remove, remove_if, remove_copy and remove_copy_if. 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   bool greater9( int ); // prototype10 11   int main()12   {13      const size_t SIZE = 10;14      array< int, SIZE > init = { 10, 2, 10, 4, 16, 6, 14, 8, 12, 10 };15      ostream_iterator< int > output( cout, " " );16 17      array< ...

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.