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 <InputIterator Iter1, InputIterator Iter2>
15//   requires HasEqualTo<Iter1, Iter2>
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
27template <class It>
28void
29test(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
36int main()
37{
38    char s[] = "1234567890";
39    test(input_iterator<char*>(s), input_iterator<char*>(s), true);
40    test(input_iterator<char*>(s), input_iterator<char*>(s+1), false);
41    test(forward_iterator<char*>(s), forward_iterator<char*>(s), true);
42    test(forward_iterator<char*>(s), forward_iterator<char*>(s+1), false);
43    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s), true);
44    test(bidirectional_iterator<char*>(s), bidirectional_iterator<char*>(s+1), false);
45    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s), true);
46    test(random_access_iterator<char*>(s), random_access_iterator<char*>(s+1), false);
47    test(s, s, true);
48    test(s, s+1, false);
49
50#if TEST_STD_VER > 14
51    {
52    constexpr const char *p = "123456789";
53    typedef std::move_iterator<const char *> MI;
54    constexpr MI it1 = std::make_move_iterator(p);
55    constexpr MI it2 = std::make_move_iterator(p + 5);
56    constexpr MI it3 = std::make_move_iterator(p);
57    static_assert(!(it1 == it2), "");
58    static_assert( (it1 == it3), "");
59    static_assert(!(it2 == it3), "");
60    }
61#endif
62}
63