blob: cfe5906fbc4694d24441a68a51b526954b2c57b4 [file] [log] [blame]
Eric Fiselier8f1e73d2016-04-21 23:38:59 +00001//===----------------------------------------------------------------------===//
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
27int main()
28{
29 // Use a builtin type so we don't get ADL lookup.
30 typedef double T[42][50];
31 {
Eric Fiselier375e2f62016-04-28 22:28:23 +000032 LIBCPP_STATIC_ASSERT(std::__is_swappable<T>::value, "");
Eric Fiselier8f1e73d2016-04-21 23:38:59 +000033#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}