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// iterator_type base() const; // constexpr since C++17
14
15#include <iterator>
16#include <cassert>
17
18#include "test_macros.h"
19#include "test_iterators.h"
20
21template <class Iter>
22TEST_CONSTEXPR_CXX17 void test() {
23 int i = 0;
24 Iter iter(&i);
25 std::reverse_iterator<Iter> const reverse(iter);
26 typename std::reverse_iterator<Iter>::iterator_type base = reverse.base();
27 assert(base == Iter(&i));
28}
29
30TEST_CONSTEXPR_CXX17 bool tests() {
31 test<bidirectional_iterator<int*> >();
32 test<random_access_iterator<int*> >();
33#if TEST_STD_VER >= 20
34 test<cpp20_random_access_iterator<int*>>();
35#endif
36 return true;
37}
38
39int main(int, char**) {
40 tests();
41#if TEST_STD_VER > 14
42 static_assert(tests(), "");
43#endif
44 return 0;
45}
46

source code of libcxx/test/std/iterators/predef.iterators/reverse.iterators/reverse.iter.conv/base.pass.cpp