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// friend constexpr decltype(auto) iter_move(const iterator& i)
12// noexcept(noexcept(invoke(i.parent_->fun_, *i.current_)))
13
14#include <ranges>
15
16#include "test_macros.h"
17#include "../types.h"
18
19constexpr bool test() {
20 int buff[8] = {0, 1, 2, 3, 4, 5, 6, 7};
21
22 {
23 std::ranges::transform_view transformView(MoveOnlyView{buff}, PlusOneMutable{});
24 auto iter = transformView.begin();
25 ASSERT_NOT_NOEXCEPT(std::ranges::iter_move(iter));
26
27 assert(std::ranges::iter_move(iter) == 1);
28 assert(std::ranges::iter_move(iter + 2) == 3);
29
30 ASSERT_SAME_TYPE(int, decltype(std::ranges::iter_move(iter)));
31 ASSERT_SAME_TYPE(int, decltype(std::ranges::iter_move(std::move(iter))));
32 }
33
34 {
35 LIBCPP_ASSERT_NOEXCEPT(std::ranges::iter_move(
36 std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneNoexcept>>&>()));
37 ASSERT_NOT_NOEXCEPT(std::ranges::iter_move(
38 std::declval<std::ranges::iterator_t<std::ranges::transform_view<MoveOnlyView, PlusOneMutable>>&>()));
39 }
40
41 return true;
42}
43
44int main(int, char**) {
45 test();
46 static_assert(test());
47
48 return 0;
49}
50

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