]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.comp/op_gt.pass.cpp
Vendor import of libc++ trunk r290819:
[FreeBSD/FreeBSD.git] / test / std / iterators / predef.iterators / move.iterators / move.iter.ops / move.iter.op.comp / op_gt.pass.cpp
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 // <iterator>
11
12 // move_iterator
13
14 // template <RandomAccessIterator Iter1, RandomAccessIterator Iter2>
15 //   requires HasLess<Iter2, Iter1>
16 //   bool
17 //   operator>(const move_iterator<Iter1>& x, const move_iterator<Iter2>& y);
18 //
19 //  constexpr in C++17
20
21 #include <iterator>
22 #include <cassert>
23
24 #include "test_macros.h"
25 #include "test_iterators.h"
26
27 template <class It>
28 void
29 test(It l, It r, bool x)
30 {
31     const std::move_iterator<It> r1(l);
32     const std::move_iterator<It> r2(r);
33     assert((r1 > r2) == x);
34 }
35
36 int main()
37 {
38     char s[] = "1234567890";
39     test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), false);
40     test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
41     test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s), true);
42     test(s, s, false);
43     test(s, s+1, false);
44     test(s+1, s, true);
45
46 #if TEST_STD_VER > 14
47     {
48     constexpr const char *p = "123456789";
49     typedef std::move_iterator<const char *> MI;
50     constexpr MI it1 = std::make_move_iterator(p);
51     constexpr MI it2 = std::make_move_iterator(p + 5);
52     constexpr MI it3 = std::make_move_iterator(p);
53     static_assert(!(it1 > it2), "");
54     static_assert(!(it1 > it3), "");
55     static_assert( (it2 > it3), "");
56     }
57 #endif
58 }