1bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===// 2bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 3f5256e16dfc425c1d466f6308d4026d529ce9e0bHoward Hinnant// The LLVM Compiler Infrastructure 4bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 5b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// This file is dual licensed under the MIT and the University of Illinois Open 6b64f8b07c104c6cc986570ac8ee0ed16a9f23976Howard Hinnant// Source Licenses. See LICENSE.TXT for details. 7bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// 8bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant//===----------------------------------------------------------------------===// 9bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 10bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// <algorithm> 11bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 12eb564e76cc3904d811c981a50ecce0659f444cc9Howard Hinnant// template<InputIterator Iter1, InputIterator Iter2, 13eb564e76cc3904d811c981a50ecce0659f444cc9Howard Hinnant// Predicate<auto, Iter1::value_type, Iter2::value_type> Pred> 14eb564e76cc3904d811c981a50ecce0659f444cc9Howard Hinnant// requires CopyConstructible<Pred> 15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// pair<Iter1, Iter2> 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// mismatch(Iter1 first1, Iter1 last1, Iter2 first2, Pred pred); 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <algorithm> 19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <functional> 20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert> 21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 2283e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h" 23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 24b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#if _LIBCPP_STD_VER > 11 25b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#define HAS_FOUR_ITERATOR_VERSION 26b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 27b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow 28b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow 29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main() 30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{ 31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; 32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant const unsigned sa = sizeof(ia)/sizeof(ia[0]); 33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; 34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::mismatch(input_iterator<const int*>(ia), 35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ia + sa), 36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ib), 37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant std::equal_to<int>()) == 38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant (std::pair<input_iterator<const int*>, 39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*> >( 40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ia+3), 41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ib+3)))); 42b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#ifdef HAS_FOUR_ITERATOR_VERSION 43b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(std::mismatch(input_iterator<const int*>(ia), 44b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia + sa), 45b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ib), 46b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ib + sa), 47b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow std::equal_to<int>()) == 48b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow (std::pair<input_iterator<const int*>, 49b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*> >( 50b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+3), 51b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ib+3)))); 52b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 53b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow 54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::mismatch(ia, ia + sa, ib, std::equal_to<int>()) == 55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant (std::pair<int*,int*>(ia+3,ib+3))); 56b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#ifdef HAS_FOUR_ITERATOR_VERSION 57b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(std::mismatch(ia, ia + sa, ib, ib + sa, std::equal_to<int>()) == 58b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow (std::pair<int*,int*>(ia+3,ib+3))); 59b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(std::mismatch(ia, ia + sa, ib, ib + 2, std::equal_to<int>()) == 60b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow (std::pair<int*,int*>(ia+2,ib+2))); 61b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant} 63