]>
git.ipfire.org Git - thirdparty/gcc.git/blob - libstdc++-v3/testsuite/20_util/is_swappable_with/value.cc
1 // { dg-do compile { target c++17 } }
3 // Copyright (C) 2016-2023 Free Software Foundation, Inc.
5 // This file is part of the GNU ISO C++ Library. This library is free
6 // software; you can redistribute it and/or modify it under the
7 // terms of the GNU General Public License as published by the
8 // Free Software Foundation; either version 3, or (at your option)
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License along
17 // with this library; see the file COPYING3. If not see
18 // <http://www.gnu.org/licenses/>.
20 #include <type_traits>
21 #include <testsuite_tr1.h>
23 #ifndef __cpp_lib_is_swappable
24 # error "Feature-test macro for is_swappable_with missing"
25 #elif __cpp_lib_is_swappable != 201603
26 # error "Feature-test macro for is_swappable_with has wrong value"
42 void swap(BoolLike
, bool&);
43 void swap(bool&, BoolLike
);
47 void swap(F0
, F0
) = delete;
51 void swap(F0
, F1
) = delete;
52 void swap(F1
, F0
) = delete;
58 void swap(F3
, F2
) = delete;
62 friend void swap(F4
, F4
) = delete;
68 using std::is_swappable_with
;
69 using namespace __gnu_test
;
71 static_assert(test_property
<is_swappable_with
, int&, int&>(true), "");
72 static_assert(test_property
<is_swappable_with
, funny::T0
,
73 funny::T0
>(true), "");
74 static_assert(test_property
<is_swappable_with
, funny::T0
,
75 const funny::T0
>(true), "");
76 static_assert(test_property
<is_swappable_with
, funny::T1
,
77 funny::T2
>(true), "");
78 static_assert(test_property
<is_swappable_with
, funny::T2
,
79 funny::T1
>(true), "");
80 static_assert(test_property
<is_swappable_with
, funny::BoolLike
,
82 static_assert(test_property
<is_swappable_with
, const funny::BoolLike
,
86 static_assert(test_property
<is_swappable_with
, int, int>(false), "");
87 static_assert(test_property
<is_swappable_with
, int&, unsigned&>(false), "");
88 static_assert(test_property
<is_swappable_with
, const int&,
89 const int&>(false), "");
90 static_assert(test_property
<is_swappable_with
, funny::F0
,
91 funny::F0
>(false), "");
92 static_assert(test_property
<is_swappable_with
, funny::F0
,
93 const funny::F0
>(false), "");
94 static_assert(test_property
<is_swappable_with
, funny::T0
,
95 funny::T1
>(false), "");
96 static_assert(test_property
<is_swappable_with
, funny::F0
,
97 funny::F1
>(false), "");
98 static_assert(test_property
<is_swappable_with
, funny::F0
,
99 const funny::F1
>(false), "");
100 static_assert(test_property
<is_swappable_with
, const funny::F0
,
101 funny::F1
>(false), "");
102 static_assert(test_property
<is_swappable_with
, funny::F2
,
103 funny::F3
>(false), "");
104 static_assert(test_property
<is_swappable_with
, funny::F2
,
105 const funny::F3
>(false), "");
106 static_assert(test_property
<is_swappable_with
, const funny::F2
,
107 funny::F3
>(false), "");
108 static_assert(test_property
<is_swappable_with
, funny::F4
,
109 funny::F4
>(false), "");
110 static_assert(test_property
<is_swappable_with
, funny::BoolLike
,
111 funny::BoolLike
>(false), "");