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