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// UNSUPPORTED: c++03, c++11, c++14, c++17
10
11// transform_view::<iterator>::base
12
13#include <ranges>
14
15#include "test_macros.h"
16#include "../types.h"
17
18constexpr bool test() {
19 {
20 using TransformView = std::ranges::transform_view<MoveOnlyView, PlusOneMutable>;
21 TransformView tv;
22 auto it = tv.begin();
23 using It = decltype(it);
24 ASSERT_SAME_TYPE(decltype(static_cast<It&>(it).base()), int* const&);
25 ASSERT_SAME_TYPE(decltype(static_cast<It&&>(it).base()), int*);
26 ASSERT_SAME_TYPE(decltype(static_cast<const It&>(it).base()), int* const&);
27 ASSERT_SAME_TYPE(decltype(static_cast<const It&&>(it).base()), int* const&);
28 ASSERT_NOEXCEPT(it.base());
29 assert(base(it.base()) == globalBuff);
30 assert(base(std::move(it).base()) == globalBuff);
31 }
32 {
33 using TransformView = std::ranges::transform_view<InputView, PlusOneMutable>;
34 TransformView tv;
35 auto it = tv.begin();
36 using It = decltype(it);
37 ASSERT_SAME_TYPE(decltype(static_cast<It&>(it).base()), const cpp20_input_iterator<int*>&);
38 ASSERT_SAME_TYPE(decltype(static_cast<It&&>(it).base()), cpp20_input_iterator<int*>);
39 ASSERT_SAME_TYPE(decltype(static_cast<const It&>(it).base()), const cpp20_input_iterator<int*>&);
40 ASSERT_SAME_TYPE(decltype(static_cast<const It&&>(it).base()), const cpp20_input_iterator<int*>&);
41 ASSERT_NOEXCEPT(it.base());
42 assert(base(it.base()) == globalBuff);
43 assert(base(std::move(it).base()) == globalBuff);
44 }
45 return true;
46}
47
48int main(int, char**) {
49 test();
50 static_assert(test());
51
52 return 0;
53}
54

source code of libcxx/test/std/ranges/range.adaptors/range.transform/iterator/base.pass.cpp