Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <algorithm> |
| 11 | |
Howard Hinnant | 664ae81 | 2010-08-22 00:08:10 +0000 | [diff] [blame] | 12 | // template<InputIterator Iter1, InputIterator Iter2> |
| 13 | // requires HasEqualTo<Iter1::value_type, Iter2::value_type> |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 14 | // pair<Iter1, Iter2> |
| 15 | // mismatch(Iter1 first1, Iter1 last1, Iter2 first2); |
| 16 | |
| 17 | #include <algorithm> |
| 18 | #include <cassert> |
| 19 | |
Marshall Clow | 3222708 | 2013-01-05 03:21:01 +0000 | [diff] [blame] | 20 | #include "test_iterators.h" |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 21 | |
Marshall Clow | 0b0bbd2 | 2013-05-09 21:14:23 +0000 | [diff] [blame] | 22 | #if _LIBCPP_STD_VER > 11 |
| 23 | #define HAS_FOUR_ITERATOR_VERSION |
| 24 | #endif |
| 25 | |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 26 | int main() |
| 27 | { |
| 28 | int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; |
| 29 | const unsigned sa = sizeof(ia)/sizeof(ia[0]); |
| 30 | int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; |
| 31 | assert(std::mismatch(input_iterator<const int*>(ia), |
| 32 | input_iterator<const int*>(ia + sa), |
| 33 | input_iterator<const int*>(ib)) == |
| 34 | (std::pair<input_iterator<const int*>, |
| 35 | input_iterator<const int*> >( |
| 36 | input_iterator<const int*>(ia+3), |
| 37 | input_iterator<const int*>(ib+3)))); |
Marshall Clow | 0b0bbd2 | 2013-05-09 21:14:23 +0000 | [diff] [blame] | 38 | |
| 39 | #ifdef HAS_FOUR_ITERATOR_VERSION |
| 40 | assert(std::mismatch(input_iterator<const int*>(ia), |
| 41 | input_iterator<const int*>(ia + sa), |
| 42 | input_iterator<const int*>(ib), |
| 43 | input_iterator<const int*>(ib + sa)) == |
| 44 | (std::pair<input_iterator<const int*>, |
| 45 | input_iterator<const int*> >( |
| 46 | input_iterator<const int*>(ia+3), |
| 47 | input_iterator<const int*>(ib+3)))); |
| 48 | |
| 49 | assert(std::mismatch(input_iterator<const int*>(ia), |
| 50 | input_iterator<const int*>(ia + sa), |
| 51 | input_iterator<const int*>(ib), |
| 52 | input_iterator<const int*>(ib + 2)) == |
| 53 | (std::pair<input_iterator<const int*>, |
| 54 | input_iterator<const int*> >( |
| 55 | input_iterator<const int*>(ia+2), |
| 56 | input_iterator<const int*>(ib+2)))); |
| 57 | #endif |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 58 | } |