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 HasLess<Iter1::value_type, Iter2::value_type> 14eb564e76cc3904d811c981a50ecce0659f444cc9Howard Hinnant// && HasLess<Iter2::value_type, Iter1::value_type> 15bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// bool 16bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant// lexicographical_compare(Iter1 first1, Iter1 last1, Iter2 first2, Iter2 last2); 17bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 18bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <algorithm> 19bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant#include <cassert> 20bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 2183e2c4d877fe2d7793868b1c6a5d9525a7c4d431Marshall Clow#include "test_iterators.h" 22bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 23bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttemplate <class Iter1, class Iter2> 24bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantvoid 25bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnanttest() 26bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{ 27bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ia[] = {1, 2, 3, 4}; 28bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant const unsigned sa = sizeof(ia)/sizeof(ia[0]); 29bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant int ib[] = {1, 2, 3}; 30bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+2)); 31bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::lexicographical_compare(ib, ib+2, ia, ia+sa)); 32bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(!std::lexicographical_compare(ia, ia+sa, ib, ib+3)); 33bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::lexicographical_compare(ib, ib+3, ia, ia+sa)); 34bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(std::lexicographical_compare(ia, ia+sa, ib+1, ib+3)); 35bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant assert(!std::lexicographical_compare(ib+1, ib+3, ia, ia+sa)); 36bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant} 37bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 38bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnantint main() 39bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant{ 40bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<input_iterator<const int*>, input_iterator<const int*> >(); 41bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<input_iterator<const int*>, forward_iterator<const int*> >(); 42bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<input_iterator<const int*>, bidirectional_iterator<const int*> >(); 43bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<input_iterator<const int*>, random_access_iterator<const int*> >(); 44bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<input_iterator<const int*>, const int*>(); 45bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 46bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<forward_iterator<const int*>, input_iterator<const int*> >(); 47bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<forward_iterator<const int*>, forward_iterator<const int*> >(); 48bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<forward_iterator<const int*>, bidirectional_iterator<const int*> >(); 49bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<forward_iterator<const int*>, random_access_iterator<const int*> >(); 50bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<forward_iterator<const int*>, const int*>(); 51bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 52bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<bidirectional_iterator<const int*>, input_iterator<const int*> >(); 53bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<bidirectional_iterator<const int*>, forward_iterator<const int*> >(); 54bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<bidirectional_iterator<const int*>, bidirectional_iterator<const int*> >(); 55bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<bidirectional_iterator<const int*>, random_access_iterator<const int*> >(); 56bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<bidirectional_iterator<const int*>, const int*>(); 57bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 58bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<random_access_iterator<const int*>, input_iterator<const int*> >(); 59bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<random_access_iterator<const int*>, forward_iterator<const int*> >(); 60bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<random_access_iterator<const int*>, bidirectional_iterator<const int*> >(); 61bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<random_access_iterator<const int*>, random_access_iterator<const int*> >(); 62bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<random_access_iterator<const int*>, const int*>(); 63bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant 64bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<const int*, input_iterator<const int*> >(); 65bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<const int*, forward_iterator<const int*> >(); 66bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<const int*, bidirectional_iterator<const int*> >(); 67bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<const int*, random_access_iterator<const int*> >(); 68bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant test<const int*, const int*>(); 69bc8d3f97eb5c958007f2713238472e0c1c8fe02Howard Hinnant} 70