]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/is_swappable_with/value.cc
1 // { dg-options "-std=gnu++17" }
2 // { dg-do compile { target c++17 } }
4 // Copyright (C) 2016-2020 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_swappable_with missing"
26 #elif __cpp_lib_is_swappable != 201603
27 # error "Feature-test macro for is_swappable_with has wrong value"
43 void swap(BoolLike
, bool&);
44 void swap(bool&, BoolLike
);
48 void swap(F0
, F0
) = delete;
52 void swap(F0
, F1
) = delete;
53 void swap(F1
, F0
) = delete;
59 void swap(F3
, F2
) = delete;
63 friend void swap(F4
, F4
) = delete;
69 using std::is_swappable_with
;
70 using namespace __gnu_test
;
72 static_assert(test_property
<is_swappable_with
, int&, int&>(true), "");
73 static_assert(test_property
<is_swappable_with
, funny::T0
,
74 funny::T0
>(true), "");
75 static_assert(test_property
<is_swappable_with
, funny::T0
,
76 const funny::T0
>(true), "");
77 static_assert(test_property
<is_swappable_with
, funny::T1
,
78 funny::T2
>(true), "");
79 static_assert(test_property
<is_swappable_with
, funny::T2
,
80 funny::T1
>(true), "");
81 static_assert(test_property
<is_swappable_with
, funny::BoolLike
,
83 static_assert(test_property
<is_swappable_with
, const funny::BoolLike
,
87 static_assert(test_property
<is_swappable_with
, int, int>(false), "");
88 static_assert(test_property
<is_swappable_with
, int&, unsigned&>(false), "");
89 static_assert(test_property
<is_swappable_with
, const int&,
90 const int&>(false), "");
91 static_assert(test_property
<is_swappable_with
, funny::F0
,
92 funny::F0
>(false), "");
93 static_assert(test_property
<is_swappable_with
, funny::F0
,
94 const funny::F0
>(false), "");
95 static_assert(test_property
<is_swappable_with
, funny::T0
,
96 funny::T1
>(false), "");
97 static_assert(test_property
<is_swappable_with
, funny::F0
,
98 funny::F1
>(false), "");
99 static_assert(test_property
<is_swappable_with
, funny::F0
,
100 const funny::F1
>(false), "");
101 static_assert(test_property
<is_swappable_with
, const funny::F0
,
102 funny::F1
>(false), "");
103 static_assert(test_property
<is_swappable_with
, funny::F2
,
104 funny::F3
>(false), "");
105 static_assert(test_property
<is_swappable_with
, funny::F2
,
106 const funny::F3
>(false), "");
107 static_assert(test_property
<is_swappable_with
, const funny::F2
,
108 funny::F3
>(false), "");
109 static_assert(test_property
<is_swappable_with
, funny::F4
,
110 funny::F4
>(false), "");
111 static_assert(test_property
<is_swappable_with
, funny::BoolLike
,
112 funny::BoolLike
>(false), "");