1 // { dg-options "-std=gnu++17" }
4 // Copyright (C) 2016-2019 Free Software Foundation, Inc.
6 // This file is part of the GNU ISO C++ Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 3, or (at your option)
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING3. If not see
19 // <http://www.gnu.org/licenses/>.
21 #include <type_traits>
22 #include <testsuite_tr1.h>
24 #ifndef __cpp_lib_is_swappable
25 # error "Feature-test macro for is_nothrow_swappable_with missing"
26 #elif __cpp_lib_is_swappable != 201603
27 # error "Feature-test macro for is_nothrow_swappable_with has wrong value"
33 void swap(T0
, T0
) noexcept
;
37 friend void swap(T1
, T1
) noexcept
;
43 void swap(T2
, T3
) noexcept
;
44 void swap(T3
, T2
) noexcept
;
46 struct T4
{ operator T0() const noexcept
; };
50 void swap(F0
, F0
) = delete;
58 void swap(F0
, F2
) noexcept
;
63 friend void swap(F3
, F3
) = delete;
68 friend void swap(F4
, F4
);
71 struct F5
{ operator T0() const; };
75 void swap(BoolLike
, bool&) noexcept
;
76 void swap(bool&, BoolLike
) noexcept
;
78 struct BoolLikeErr
{};
80 void swap(BoolLikeErr
, bool&);
81 void swap(bool&, BoolLikeErr
) noexcept
;
86 using std::is_nothrow_swappable_with
;
87 using namespace __gnu_test
;
89 static_assert(test_property
<is_nothrow_swappable_with
, int&, int&>(true),
91 static_assert(test_property
<is_nothrow_swappable_with
, funny::T0
,
92 funny::T0
>(true), "");
93 static_assert(test_property
<is_nothrow_swappable_with
, funny::T0
,
94 const funny::T0
>(true), "");
95 static_assert(test_property
<is_nothrow_swappable_with
, funny::T1
,
96 funny::T1
>(true), "");
97 static_assert(test_property
<is_nothrow_swappable_with
, funny::T1
,
98 const funny::T1
>(true), "");
99 static_assert(test_property
<is_nothrow_swappable_with
, funny::T2
,
100 funny::T3
>(true), "");
101 static_assert(test_property
<is_nothrow_swappable_with
, funny::T3
,
102 funny::T2
>(true), "");
103 static_assert(test_property
<is_nothrow_swappable_with
, funny::T0
,
104 funny::T4
>(true), "");
105 static_assert(test_property
<is_nothrow_swappable_with
, funny::T4
,
106 funny::T0
>(true), "");
107 static_assert(test_property
<is_nothrow_swappable_with
, funny::BoolLike
,
109 static_assert(test_property
<is_nothrow_swappable_with
, const funny::BoolLike
,
113 static_assert(test_property
<is_nothrow_swappable_with
, const int&,
114 const int&>(false), "");
115 static_assert(test_property
<is_nothrow_swappable_with
, int&,
116 unsigned&>(false), "");
117 static_assert(test_property
<is_nothrow_swappable_with
, funny::F0
,
118 funny::F0
>(false), "");
119 static_assert(test_property
<is_nothrow_swappable_with
, funny::F0
,
120 const funny::F0
>(false), "");
121 static_assert(test_property
<is_nothrow_swappable_with
, funny::F1
,
122 funny::F1
>(false), "");
123 static_assert(test_property
<is_nothrow_swappable_with
, funny::F1
,
124 const funny::F1
>(false), "");
125 static_assert(test_property
<is_nothrow_swappable_with
, funny::F0
,
126 funny::F2
>(false), "");
127 static_assert(test_property
<is_nothrow_swappable_with
, funny::F2
,
128 funny::F0
>(false), "");
129 static_assert(test_property
<is_nothrow_swappable_with
, funny::F3
,
130 funny::F3
>(false), "");
131 static_assert(test_property
<is_nothrow_swappable_with
, funny::F3
,
132 const funny::F3
>(false), "");
133 static_assert(test_property
<is_nothrow_swappable_with
, funny::F4
,
134 funny::F4
>(false), "");
135 static_assert(test_property
<is_nothrow_swappable_with
, funny::F4
,
136 const funny::F4
>(false), "");
137 static_assert(test_property
<is_nothrow_swappable_with
, funny::T0
,
138 funny::F5
>(false), "");
139 static_assert(test_property
<is_nothrow_swappable_with
, funny::F5
,
140 funny::T0
>(false), "");
141 static_assert(test_property
<is_nothrow_swappable_with
, funny::BoolLikeErr
,
143 static_assert(test_property
<is_nothrow_swappable_with
,
144 const funny::BoolLikeErr
, bool&>(false), "");