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 // type_traits
10 
11 // is_swappable
12 
13 // IMPORTANT: The include order is part of the test. We want to pick up
14 // the following definitions in this order:
15 //   1) is_swappable, is_nothrow_swappable
16 //   2) iter_swap, swap_ranges
17 //   3) swap(T (&)[N], T (&)[N])
18 // This test checks that (1) and (2) see forward declarations
19 // for (3).
20 #include <type_traits>
21 #include <algorithm>
22 #include <utility>
23 
24 #include "test_macros.h"
25 
main(int,char **)26 int main(int, char**)
27 {
28     // Use a builtin type so we don't get ADL lookup.
29     typedef double T[17][29];
30     {
31         LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, "");
32 #if TEST_STD_VER > 14
33         static_assert(std::is_swappable_v<T>, "");
34 #endif
35     }
36     {
37         T t1 = {};
38         T t2 = {};
39        std::iter_swap(t1, t2);
40        std::swap_ranges(t1, t1 + 17, t2);
41     }
42 
43   return 0;
44 }
45