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, c++20 |
10 | |
11 | // constexpr iterator& operator+=(difference_type n); |
12 | |
13 | #include <ranges> |
14 | #include <cassert> |
15 | #include <concepts> |
16 | |
17 | constexpr bool test() { |
18 | std::ranges::repeat_view<int> v(10); |
19 | using Iter = std::ranges::iterator_t<std::ranges::repeat_view<int>>; |
20 | auto iter1 = v.begin() + 10; |
21 | auto iter2 = v.begin() + 10; |
22 | assert(iter1 == iter2); |
23 | iter1 += 5; |
24 | assert(iter1 != iter2); |
25 | assert(iter1 == iter2 + 5); |
26 | |
27 | static_assert(std::same_as<decltype(iter2 += 5), Iter&>); |
28 | assert(std::addressof(iter2) == std::addressof(iter2 += 5)); |
29 | |
30 | return true; |
31 | } |
32 | |
33 | int main(int, char**) { |
34 | test(); |
35 | static_assert(test()); |
36 | |
37 | return 0; |
38 | } |
39 | |