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, c++17
12 // concept movable = see below;
17 #include <forward_list>
21 #include <unordered_map>
24 #include "test_macros.h"
26 #ifndef TEST_HAS_NO_THREADS
30 #include "type_classification/moveconstructible.h"
31 #include "type_classification/movable.h"
34 static_assert(std::movable
<int>);
35 static_assert(std::movable
<int volatile>);
36 static_assert(std::movable
<int*>);
37 static_assert(std::movable
<int const*>);
38 static_assert(std::movable
<int volatile*>);
39 static_assert(std::movable
<int const volatile*>);
40 static_assert(std::movable
<int (*)()>);
43 static_assert(std::movable
<S
>);
44 static_assert(std::movable
<int S::*>);
45 static_assert(std::movable
<int (S::*)()>);
46 static_assert(std::movable
<int (S::*)() noexcept
>);
47 static_assert(std::movable
<int (S::*)() &>);
48 static_assert(std::movable
<int (S::*)() & noexcept
>);
49 static_assert(std::movable
<int (S::*)() &&>);
50 static_assert(std::movable
<int (S::*)() && noexcept
>);
51 static_assert(std::movable
<int (S::*)() const>);
52 static_assert(std::movable
<int (S::*)() const noexcept
>);
53 static_assert(std::movable
<int (S::*)() const&>);
54 static_assert(std::movable
<int (S::*)() const & noexcept
>);
55 static_assert(std::movable
<int (S::*)() const&&>);
56 static_assert(std::movable
<int (S::*)() const && noexcept
>);
57 static_assert(std::movable
<int (S::*)() volatile>);
58 static_assert(std::movable
<int (S::*)() volatile noexcept
>);
59 static_assert(std::movable
<int (S::*)() volatile&>);
60 static_assert(std::movable
<int (S::*)() volatile & noexcept
>);
61 static_assert(std::movable
<int (S::*)() volatile&&>);
62 static_assert(std::movable
<int (S::*)() volatile && noexcept
>);
63 static_assert(std::movable
<int (S::*)() const volatile>);
64 static_assert(std::movable
<int (S::*)() const volatile noexcept
>);
65 static_assert(std::movable
<int (S::*)() const volatile&>);
66 static_assert(std::movable
<int (S::*)() const volatile & noexcept
>);
67 static_assert(std::movable
<int (S::*)() const volatile&&>);
68 static_assert(std::movable
<int (S::*)() const volatile && noexcept
>);
70 static_assert(std::movable
<std::deque
<int> >);
71 static_assert(std::movable
<std::forward_list
<int> >);
72 static_assert(std::movable
<std::list
<int> >);
73 static_assert(std::movable
<std::optional
<std::vector
<int> > >);
74 static_assert(std::movable
<std::vector
<int> >);
76 static_assert(std::movable
<has_volatile_member
>);
77 static_assert(std::movable
<has_array_member
>);
80 static_assert(!std::movable
<int&>);
81 static_assert(!std::movable
<int const&>);
82 static_assert(!std::movable
<int volatile&>);
83 static_assert(!std::movable
<int const volatile&>);
84 static_assert(!std::movable
<int&&>);
85 static_assert(!std::movable
<int const&&>);
86 static_assert(!std::movable
<int volatile&&>);
87 static_assert(!std::movable
<int const volatile&&>);
88 static_assert(!std::movable
<int()>);
89 static_assert(!std::movable
<int (&)()>);
90 static_assert(!std::movable
<int[5]>);
92 // Core non-move assignable.
93 static_assert(!std::movable
<int const>);
94 static_assert(!std::movable
<int const volatile>);
96 static_assert(!std::movable
<DeletedMoveCtor
>);
97 static_assert(!std::movable
<ImplicitlyDeletedMoveCtor
>);
98 static_assert(!std::movable
<DeletedMoveAssign
>);
99 static_assert(!std::movable
<ImplicitlyDeletedMoveAssign
>);
100 static_assert(!std::movable
<NonMovable
>);
101 static_assert(!std::movable
<DerivedFromNonMovable
>);
102 static_assert(!std::movable
<HasANonMovable
>);
104 static_assert(std::movable
<cpp03_friendly
>);
105 static_assert(std::movable
<const_move_ctor
>);
106 static_assert(std::movable
<volatile_move_ctor
>);
107 static_assert(std::movable
<cv_move_ctor
>);
108 static_assert(std::movable
<multi_param_move_ctor
>);
109 static_assert(!std::movable
<not_quite_multi_param_move_ctor
>);
111 static_assert(!std::assignable_from
<copy_with_mutable_parameter
&,
112 copy_with_mutable_parameter
>);
113 static_assert(!std::movable
<copy_with_mutable_parameter
>);
115 static_assert(!std::movable
<const_move_assignment
>);
116 static_assert(std::movable
<volatile_move_assignment
>);
117 static_assert(!std::movable
<cv_move_assignment
>);
119 static_assert(!std::movable
<const_move_assign_and_traditional_move_assign
>);
120 static_assert(!std::movable
<volatile_move_assign_and_traditional_move_assign
>);
121 static_assert(!std::movable
<cv_move_assign_and_traditional_move_assign
>);
122 static_assert(std::movable
<const_move_assign_and_default_ops
>);
123 static_assert(std::movable
<volatile_move_assign_and_default_ops
>);
124 static_assert(std::movable
<cv_move_assign_and_default_ops
>);
126 static_assert(!std::movable
<has_const_member
>);
127 static_assert(!std::movable
<has_cv_member
>);
128 static_assert(!std::movable
<has_lvalue_reference_member
>);
129 static_assert(!std::movable
<has_rvalue_reference_member
>);
130 static_assert(!std::movable
<has_function_ref_member
>);
132 static_assert(std::movable
<deleted_assignment_from_const_rvalue
>);
134 // `move_constructible and assignable_from<T&, T>` implies `swappable<T>`,
135 // so there's nothing to test for the case of non-swappable.