O'Reilly logo

C++11 for Programmers, Second Edition by Harvey M. Deitel, Abbey Deitel, Paul J. Deitel

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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< ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required