Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // type_traits |
| 11 | |
| 12 | // is_swappable |
| 13 | |
| 14 | // IMPORTANT: The include order is part of the test. We want to pick up |
| 15 | // the following definitions in this order: |
| 16 | // 1) is_swappable, is_nothrow_swappable |
| 17 | // 2) iter_swap, swap_ranges |
| 18 | // 3) swap(T (&)[N], T(&)[N] |
| 19 | // This test checks that (1) and (2) see forward declarations |
| 20 | // for (3). |
| 21 | #include <type_traits> |
| 22 | #include <algorithm> |
| 23 | #include <utility> |
| 24 | |
| 25 | #include "test_macros.h" |
| 26 | |
| 27 | int main() |
| 28 | { |
| 29 | // Use a builtin type so we don't get ADL lookup. |
| 30 | typedef double T[42][50]; |
| 31 | { |
Eric Fiselier | 375e2f6 | 2016-04-28 22:28:23 +0000 | [diff] [blame] | 32 | LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, ""); |
Eric Fiselier | 8f1e73d | 2016-04-21 23:38:59 +0000 | [diff] [blame] | 33 | #if TEST_STD_VER > 14 |
| 34 | static_assert(std::is_swappable_v<T>); |
| 35 | #endif |
| 36 | } |
| 37 | { |
| 38 | T t1 = {}; |
| 39 | T t2 = {}; |
| 40 | std::iter_swap(t1, t2); |
| 41 | std::swap_ranges(t1, t1 + 42, t2); |
| 42 | } |
| 43 | } |