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 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14
15 #include <type_traits>
17 #include "test_macros.h"
23 A
& operator=(A
const&) = delete;
28 B
& operator=(B
const&) = delete;
39 void swap(A
&, C
&) {} // missing swap(C, A)
44 void swap(M
&&, M
&&) {}
52 // Test that is_swappable_with doesn't apply an lvalue reference
53 // to the type. Instead it is up to the user.
54 static_assert(!std::is_swappable_with
<int, int>::value
, "");
55 static_assert(std::is_swappable_with
<int&, int&>::value
, "");
56 static_assert(std::is_swappable_with
<M
, M
>::value
, "");
57 static_assert(std::is_swappable_with
<A
&, A
&>::value
, "");
60 // test that heterogeneous swap is allowed only if both 'swap(A, B)' and
61 // 'swap(B, A)' are valid.
62 static_assert(std::is_swappable_with
<A
&, B
&>::value
, "");
63 static_assert(!std::is_swappable_with
<A
&, C
&>::value
, "");
64 static_assert(!std::is_swappable_with
<D
&, C
&>::value
, "");
67 // test that cv void is guarded against as required.
68 static_assert(!std::is_swappable_with_v
<void, int>, "");
69 static_assert(!std::is_swappable_with_v
<int, void>, "");
70 static_assert(!std::is_swappable_with_v
<const void, const volatile void>, "");
73 // test for presence of is_swappable_with_v
74 static_assert(std::is_swappable_with_v
<int&, int&>, "");
75 static_assert(!std::is_swappable_with_v
<D
&, C
&>, "");