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 Iter>
15//   move_iterator<Iter>
16//   operator+(Iter::difference_type n, const move_iterator<Iter>& x);
17//
18//  constexpr in C++17
19
20#include <iterator>
21#include <cassert>
22
23#include "test_macros.h"
24#include "test_iterators.h"
25
26template <class It>
27void
28test(It i, typename std::iterator_traits<It>::difference_type n, It x)
29{
30    const std::move_iterator<It> r(i);
31    std::move_iterator<It> rr = n + r;
32    assert(rr.base() == x);
33}
34
35int main()
36{
37    char s[] = "1234567890";
38    test(random_access_iterator<char*>(s+5), 5, random_access_iterator<char*>(s+10));
39    test(s+5, 5, s+10);
40
41#if TEST_STD_VER > 14
42    {
43    constexpr const char *p = "123456789";
44    typedef std::move_iterator<const char *> MI;
45    constexpr MI it1 = std::make_move_iterator(p);
46    constexpr MI it2 = std::make_move_iterator(p + 5);
47    constexpr MI it3 = it1 + 5;
48    static_assert(it1 != it2, "");
49    static_assert(it1 != it3, "");
50    static_assert(it2 == it3, "");
51    }
52#endif
53}
54