1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9// <iterator>
10
11// move_iterator
12
13// move_iterator& operator--();
14//
15// constexpr in C++17
16
17#include <iterator>
18#include <cassert>
19
20#include "test_macros.h"
21#include "test_iterators.h"
22
23template <class It>
24void
25test(It i, It x)
26{
27 std::move_iterator<It> r(i);
28 std::move_iterator<It>& rr = --r;
29 assert(r.base() == x);
30 assert(&rr == &r);
31}
32
33int main(int, char**)
34{
35 char s[] = "123";
36 test(bidirectional_iterator<char*>(s+1), bidirectional_iterator<char*>(s));
37 test(random_access_iterator<char*>(s+1), random_access_iterator<char*>(s));
38 test(i: s+1, x: s);
39
40#if TEST_STD_VER > 14
41 {
42 constexpr const char *p = "123456789";
43 typedef std::move_iterator<const char *> MI;
44 constexpr MI it1 = std::make_move_iterator(p);
45 constexpr MI it2 = std::make_move_iterator(p+1);
46 static_assert(it1 != it2, "");
47 constexpr MI it3 = -- std::make_move_iterator(p+1);
48 static_assert(it1 == it3, "");
49 static_assert(it2 != it3, "");
50 }
51#endif
52
53 return 0;
54}
55

source code of libcxx/test/std/iterators/predef.iterators/move.iterators/move.iter.ops/move.iter.op.decr/pre.pass.cpp