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 // UNSUPPORTED: libcpp-has-no-incomplete-ranges
11 
12 // transform_view::<iterator>::operator{++,--,+=,-=}
13 
14 #include <ranges>
15 
16 #include "test_macros.h"
17 #include "../types.h"
18 
test()19 constexpr bool test() {
20   std::ranges::transform_view<MoveOnlyView, PlusOne> transformView;
21   auto iter = std::move(transformView).begin();
22   assert((++iter).base() == globalBuff + 1);
23 
24   assert((iter++).base() == globalBuff + 1);
25   assert(iter.base() == globalBuff + 2);
26 
27   assert((--iter).base() == globalBuff + 1);
28   assert((iter--).base() == globalBuff + 1);
29   assert(iter.base() == globalBuff);
30 
31   // Check that decltype(InputIter++) == void.
32   ASSERT_SAME_TYPE(decltype(
33     std::declval<std::ranges::iterator_t<std::ranges::transform_view<InputView, PlusOne>>>()++),
34     void);
35 
36   assert((iter += 4).base() == globalBuff + 4);
37   assert((iter -= 3).base() == globalBuff + 1);
38 
39   return true;
40 }
41 
main(int,char **)42 int main(int, char**) {
43   test();
44   static_assert(test());
45 
46   return 0;
47 }
48