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);
16 #include "test_macros.h"
17 // std::array is explicitly allowed to be initialized with A a = { init-list };.
18 // Disable the missing braces warning for this reason.
19 #include "disable_missing_braces_warning.h"
24 NonSwappable(NonSwappable
const&);
25 NonSwappable
& operator=(NonSwappable
const&);
29 decltype(swap(std::declval
<Tp
>(), std::declval
<Tp
>()))
33 std::false_type
can_swap_imp(...);
36 struct can_swap
: std::is_same
<decltype(can_swap_imp
<Tp
>(0)), void> {};
42 typedef std::array
<T
, 3> C
;
46 assert(c1
.size() == 3);
50 assert(c2
.size() == 3);
57 typedef std::array
<T
, 0> C
;
61 assert(c1
.size() == 0);
62 assert(c2
.size() == 0);
65 typedef NonSwappable T
;
66 typedef std::array
<T
, 0> C0
;
67 static_assert(can_swap
<C0
&>::value
, "");
71 #if TEST_STD_VER >= 11
72 static_assert(noexcept(swap(l
, r
)), "");
75 #if TEST_STD_VER >= 11
77 // NonSwappable is still considered swappable in C++03 because there
78 // is no access control SFINAE.
79 typedef NonSwappable T
;
80 typedef std::array
<T
, 42> C1
;
81 static_assert(!can_swap
<C1
&>::value
, "");