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