1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <algorithm> 11 12// template<InputIterator Iter1, InputIterator Iter2> 13// requires HasEqualTo<Iter1::value_type, Iter2::value_type> 14// pair<Iter1, Iter2> 15// mismatch(Iter1 first1, Iter1 last1, Iter2 first2); 16 17#include <algorithm> 18#include <cassert> 19 20#include "test_macros.h" 21#include "test_iterators.h" 22 23 24int main() 25{ 26 int ia[] = {0, 1, 2, 2, 0, 1, 2, 3}; 27 const unsigned sa = sizeof(ia)/sizeof(ia[0]); 28 int ib[] = {0, 1, 2, 3, 0, 1, 2, 3}; 29 const unsigned sb = sizeof(ib)/sizeof(ib[0]); ((void)sb); // unused in c++11 30 31 typedef input_iterator<const int*> II; 32 typedef random_access_iterator<const int*> RAI; 33 34 assert(std::mismatch(II(ia), II(ia + sa), II(ib)) 35 == (std::pair<II, II>(II(ia+3), II(ib+3)))); 36 37 assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib)) 38 == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3)))); 39 40#if TEST_STD_VER > 11 // We have the four iteration version 41 assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+sb)) 42 == (std::pair<II, II>(II(ia+3), II(ib+3)))); 43 44 assert(std::mismatch(RAI(ia), RAI(ia + sa), RAI(ib), RAI(ib+sb)) 45 == (std::pair<RAI, RAI>(RAI(ia+3), RAI(ib+3)))); 46 47 48 assert(std::mismatch(II(ia), II(ia + sa), II(ib), II(ib+2)) 49 == (std::pair<II, II>(II(ia+2), II(ib+2)))); 50#endif 51} 52