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 // friend constexpr void iter_swap(const iterator& x, const iterator& y);
13 
14 #include <cassert>
15 #include <ranges>
16 
17 #include "test_macros.h"
18 #include "../types.h"
19 
20 constexpr bool test() {
21   int buffer[4][4] = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}};
22 
23   std::ranges::join_view jv(buffer);
24   auto iter1 = jv.begin();
25   auto iter2 = std::next(jv.begin());
26   assert(*iter1 == 1);
27   assert(*iter2 == 2);
28   std::ranges::swap(iter1, iter2);
29   assert(*iter1 == 2);
30   assert(*iter2 == 1);
31 
32   static_assert(noexcept(std::ranges::iter_swap(iter1, iter2)));
33 
34   return true;
35 }
36 
37 int main(int, char**) {
38   test();
39   static_assert(test());
40 
41   return 0;
42 }
43