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// requires HasEqualTo<Iter1::value_type, Iter2::value_type> 14bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// bool 15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// equal(Iter1 first1, Iter1 last1, Iter2 first2); 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <algorithm> 18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert> 19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 2083e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h" 21bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 22b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#if _LIBCPP_STD_VER > 11 23171771a9f5fd9e5dbbc6d6a2d9dfb0d8532b5155Howard Hinnant#define HAS_FOUR_ITERATOR_VERSION 24b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 25b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow 26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main() 27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{ 28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ia[] = {0, 1, 2, 3, 4, 5}; 29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant const unsigned s = sizeof(ia)/sizeof(ia[0]); 30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ib[s] = {0, 1, 2, 5, 4, 5}; 31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::equal(input_iterator<const int*>(ia), 32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ia+s), 33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ia))); 34b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#ifdef HAS_FOUR_ITERATOR_VERSION 35b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(std::equal(input_iterator<const int*>(ia), 36b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+s), 37b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia), 38b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+s))); 39b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(std::equal(random_access_iterator<const int*>(ia), 40b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia+s), 41b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia), 42b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia+s))); 43b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(!std::equal(input_iterator<const int*>(ia), 45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ia+s), 46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant input_iterator<const int*>(ib))); 47b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#ifdef HAS_FOUR_ITERATOR_VERSION 48b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(!std::equal(input_iterator<const int*>(ia), 49b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+s), 50b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ib), 51b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ib+s))); 52b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(!std::equal(random_access_iterator<const int*>(ia), 53b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia+s), 54b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ib), 55b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ib+s))); 56b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(!std::equal(input_iterator<const int*>(ia), 57b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+s), 58b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia), 59b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow input_iterator<const int*>(ia+s-1))); 60b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow assert(!std::equal(random_access_iterator<const int*>(ia), 61b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia+s), 62b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia), 63b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow random_access_iterator<const int*>(ia+s-1))); 64b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow 65b30abdd07a6c6374f4716b7e3a2e343f5db77961Marshall Clow#endif 66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant} 67