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// friend constexpr iterator operator+(iterator i, difference_type n);
12// friend constexpr iterator operator+(difference_type n, iterator i);
13
14#include <ranges>
15#include <cassert>
16#include <concepts>
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 iter = v.begin();
22 assert(iter + 5 == v.begin() + 5);
23 assert(5 + iter == v.begin() + 5);
24 assert(2 + iter == v.begin() + 2);
25 assert(3 + iter == v.begin() + 3);
26
27 static_assert(std::same_as<decltype(iter + 5), Iter>);
28 static_assert(std::same_as<decltype(5 + iter), Iter>);
29
30 return true;
31}
32
33int main(int, char**) {
34 test();
35 static_assert(test());
36
37 return 0;
38}
39

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