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// reverse_iterator
12
13// reverse_iterator operator--(int); // constexpr in C++17
14
15#include <iterator>
16#include <cassert>
17
18#include "test_macros.h"
19#include "test_iterators.h"
20
21template <class It>
22TEST_CONSTEXPR_CXX17 void test(It i, It x) {
23 std::reverse_iterator<It> r(i);
24 std::reverse_iterator<It> rr = r--;
25 assert(r.base() == x);
26 assert(rr.base() == i);
27}
28
29TEST_CONSTEXPR_CXX17 bool tests() {
30 const char* s = "123";
31 test(bidirectional_iterator<const char*>(s+1), bidirectional_iterator<const char*>(s+2));
32 test(random_access_iterator<const char*>(s+1), random_access_iterator<const char*>(s+2));
33 test(s+1, s+2);
34 return true;
35}
36
37int main(int, char**) {
38 tests();
39#if TEST_STD_VER > 14
40 static_assert(tests(), "");
41#endif
42 return 0;
43}
44

source code of libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.nav/postdecrement.pass.cpp