1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class T, size_t N> void swap(array<T,N>& x, array<T,N>& y);
17 #include "test_macros.h"
20 TEST_CONSTEXPR
NonSwappable() { }
22 NonSwappable(NonSwappable
const&);
23 NonSwappable
& operator=(NonSwappable
const&);
27 decltype(swap(std::declval
<Tp
>(), std::declval
<Tp
>()))
31 std::false_type
can_swap_imp(...);
34 struct can_swap
: std::is_same
<decltype(can_swap_imp
<Tp
>(0)), void> { };
36 TEST_CONSTEXPR_CXX20
bool tests()
40 typedef std::array
<T
, 3> C
;
44 assert(c1
.size() == 3);
48 assert(c2
.size() == 3);
55 typedef std::array
<T
, 0> C
;
59 assert(c1
.size() == 0);
60 assert(c2
.size() == 0);
63 typedef NonSwappable T
;
64 typedef std::array
<T
, 0> C0
;
65 static_assert(can_swap
<C0
&>::value
, "");
69 #if TEST_STD_VER >= 11
70 static_assert(noexcept(swap(l
, r
)), "");
73 #if TEST_STD_VER >= 11
75 // NonSwappable is still considered swappable in C++03 because there
76 // is no access control SFINAE.
77 typedef NonSwappable T
;
78 typedef std::array
<T
, 42> C1
;
79 static_assert(!can_swap
<C1
&>::value
, "");
89 #if TEST_STD_VER >= 20
90 static_assert(tests(), "");