16.3.2. equal, mismatch and lexicographical_compare

Figure 16.2 demonstrates comparing sequences of values for equality using algorithms equal, mismatch and lexicographical_compare.

 1   // Fig. 16.2: fig16_02.cpp 2   // Algorithms equal, mismatch and lexicographical_compare. 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 = 10;12      array< int, SIZE > a1 = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };13      array< int, SIZE > a2( a1 ); // initializes a2 with copy of a114      array< int, SIZE > a3 = { 1, 2, 3, 4, 1000, 6

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.