Debian Codegraph @

libcxx/test/std/algorithms/alg.modifying.operations/alg.swap/iter_swap.pass.cpp

raw
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 // <algorithm>
10
11 // template<Iterator Iter1, Iterator Iter2>
12 // requires HasSwap<Iter1::reference, Iter2::reference>
13 // void
14 // iter_swap(Iter1 a, Iter2 b);
15
16 #include <algorithm>
17 #include <cassert>
18
19 #include "test_macros.h"
20
21 #if TEST_STD_VER > 17
22 constexpr bool test_swap_constexpr()
23 {
24 int i = 1;
25 int j = 2;
26 std::iter_swap(&i, &j);
27 return i == 2 && j == 1;
28 }
29 #endif // TEST_STD_VER > 17
30
31 int main(int, char**)
32 {
33 int i = 1;
34 int j = 2;
35 std::iter_swap(&i, &j);
36 assert(i == 2);
37 assert(j == 1);
38
39 #if TEST_STD_VER > 17
40 static_assert(test_swap_constexpr());
41 #endif // TEST_STD_VER > 17
42
43 return 0;
44 }