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>::operator{+,-} |
12 | |
13 | #include <ranges> |
14 | |
15 | #include "test_macros.h" |
16 | #include "../types.h" |
17 | |
18 | constexpr bool test() { |
19 | std::ranges::transform_view<MoveOnlyView, PlusOneMutable> transformView1; |
20 | auto iter1 = std::move(transformView1).begin(); |
21 | std::ranges::transform_view<MoveOnlyView, PlusOneMutable> transformView2; |
22 | [[maybe_unused]] auto iter2 = std::move(transformView2).begin(); |
23 | iter1 += 4; |
24 | assert((iter1 + 1).base() == globalBuff + 5); |
25 | assert((1 + iter1).base() == globalBuff + 5); |
26 | assert((iter1 - 1).base() == globalBuff + 3); |
27 | LIBCPP_ASSERT(iter1 - iter2 == 4); |
28 | assert((iter1 + 2) - 2 == iter1); |
29 | assert((iter1 - 2) + 2 == iter1); |
30 | |
31 | return true; |
32 | } |
33 | |
34 | int main(int, char**) { |
35 | test(); |
36 | static_assert(test()); |
37 | |
38 | return 0; |
39 | } |
40 | |