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

source code of libcxx/test/std/ranges/range.factories/range.repeat.view/iterator/plus_eq.pass.cpp