| 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 | |
| 26 | int main(int, char**) { |
| 27 | // Use a builtin type so we don't get ADL lookup. |
| 28 | typedef double T[17][29]; |
| 29 | { |
| 30 | LIBCPP_STATIC_ASSERT(std::__is_swappable_v<T>, "" ); |
| 31 | #if TEST_STD_VER > 14 |
| 32 | static_assert(std::is_swappable_v<T>, "" ); |
| 33 | #endif |
| 34 | } |
| 35 | { |
| 36 | T t1 = {}; |
| 37 | T t2 = {}; |
| 38 | std::iter_swap(t1, t2); |
| 39 | std::swap_ranges(t1, t1 + 17, t2); |
| 40 | } |
| 41 | |
| 42 | return 0; |
| 43 | } |
| 44 | |