| 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, PlusOne> transformView; |
| 20 | auto iter = std::move(transformView).begin(); |
| 21 | assert((++iter).base() == globalBuff + 1); |
| 22 | |
| 23 | assert((iter++).base() == globalBuff + 1); |
| 24 | assert(iter.base() == globalBuff + 2); |
| 25 | |
| 26 | assert((--iter).base() == globalBuff + 1); |
| 27 | assert((iter--).base() == globalBuff + 1); |
| 28 | assert(iter.base() == globalBuff); |
| 29 | |
| 30 | // Check that decltype(InputIter++) == void. |
| 31 | ASSERT_SAME_TYPE(decltype( |
| 32 | std::declval<std::ranges::iterator_t<std::ranges::transform_view<InputView, PlusOne>>>()++), |
| 33 | void); |
| 34 | |
| 35 | assert((iter += 4).base() == globalBuff + 4); |
| 36 | assert((iter -= 3).base() == globalBuff + 1); |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | int main(int, char**) { |
| 42 | test(); |
| 43 | static_assert(test()); |
| 44 | |
| 45 | return 0; |
| 46 | } |
| 47 | |