Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / concepts / concepts.object / copyable.compile.pass.cpp
blobaccd6141dae844fc59b6c4b5a3d95d41e5999cc5
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // UNSUPPORTED: c++03, c++11, c++14, c++17
11 // template<class T>
12 // concept copyable = see below;
14 #include <concepts>
16 #include <deque>
17 #include <forward_list>
18 #include <list>
19 #include <map>
20 #include <memory>
21 #include <optional>
22 #include <unordered_map>
23 #include <vector>
25 #include "type_classification/copyable.h"
27 static_assert(std::copyable<int>);
28 static_assert(std::copyable<int volatile>);
29 static_assert(std::copyable<int*>);
30 static_assert(std::copyable<int const*>);
31 static_assert(std::copyable<int volatile*>);
32 static_assert(std::copyable<int volatile const*>);
33 static_assert(std::copyable<int (*)()>);
35 struct S {};
36 static_assert(std::copyable<S>);
37 static_assert(std::copyable<int S::*>);
38 static_assert(std::copyable<int (S::*)()>);
39 static_assert(std::copyable<int (S::*)() noexcept>);
40 static_assert(std::copyable<int (S::*)() &>);
41 static_assert(std::copyable<int (S::*)() & noexcept>);
42 static_assert(std::copyable<int (S::*)() &&>);
43 static_assert(std::copyable<int (S::*)() && noexcept>);
44 static_assert(std::copyable<int (S::*)() const>);
45 static_assert(std::copyable<int (S::*)() const noexcept>);
46 static_assert(std::copyable<int (S::*)() const&>);
47 static_assert(std::copyable<int (S::*)() const & noexcept>);
48 static_assert(std::copyable<int (S::*)() const&&>);
49 static_assert(std::copyable<int (S::*)() const && noexcept>);
50 static_assert(std::copyable<int (S::*)() volatile>);
51 static_assert(std::copyable<int (S::*)() volatile noexcept>);
52 static_assert(std::copyable<int (S::*)() volatile&>);
53 static_assert(std::copyable<int (S::*)() volatile & noexcept>);
54 static_assert(std::copyable<int (S::*)() volatile&&>);
55 static_assert(std::copyable<int (S::*)() volatile && noexcept>);
56 static_assert(std::copyable<int (S::*)() const volatile>);
57 static_assert(std::copyable<int (S::*)() const volatile noexcept>);
58 static_assert(std::copyable<int (S::*)() const volatile&>);
59 static_assert(std::copyable<int (S::*)() const volatile & noexcept>);
60 static_assert(std::copyable<int (S::*)() const volatile&&>);
61 static_assert(std::copyable<int (S::*)() const volatile && noexcept>);
63 static_assert(std::copyable<std::vector<int> >);
64 static_assert(std::copyable<std::deque<int> >);
65 static_assert(std::copyable<std::forward_list<int> >);
66 static_assert(std::copyable<std::list<int> >);
67 static_assert(std::copyable<std::shared_ptr<std::unique_ptr<int> > >);
68 static_assert(std::copyable<std::optional<std::vector<int> > >);
69 static_assert(std::copyable<std::vector<int> >);
70 static_assert(std::copyable<std::vector<std::unique_ptr<int> > >);
72 static_assert(std::copyable<has_volatile_member>);
73 static_assert(std::copyable<has_array_member>);
75 // Not objects
76 static_assert(!std::copyable<void>);
77 static_assert(!std::copyable<int&>);
78 static_assert(!std::copyable<int const&>);
79 static_assert(!std::copyable<int volatile&>);
80 static_assert(!std::copyable<int const volatile&>);
81 static_assert(!std::copyable<int&&>);
82 static_assert(!std::copyable<int const&&>);
83 static_assert(!std::copyable<int volatile&&>);
84 static_assert(!std::copyable<int const volatile&&>);
85 static_assert(!std::copyable<int()>);
86 static_assert(!std::copyable<int (&)()>);
87 static_assert(!std::copyable<int[5]>);
89 // Not copy constructible or copy assignable
90 static_assert(!std::copyable<std::unique_ptr<int> >);
92 // Not assignable
93 static_assert(!std::copyable<int const>);
94 static_assert(!std::copyable<int const volatile>);
95 static_assert(std::copyable<const_copy_assignment const>);
96 static_assert(!std::copyable<volatile_copy_assignment volatile>);
97 static_assert(std::copyable<cv_copy_assignment const volatile>);
99 static_assert(!std::copyable<no_copy_constructor>);
100 static_assert(!std::copyable<no_copy_assignment>);
102 static_assert(std::is_copy_assignable_v<no_copy_assignment_mutable>);
103 static_assert(!std::copyable<no_copy_assignment_mutable>);
104 static_assert(!std::copyable<derived_from_noncopyable>);
105 static_assert(!std::copyable<has_noncopyable>);
106 static_assert(!std::copyable<has_const_member>);
107 static_assert(!std::copyable<has_cv_member>);
108 static_assert(!std::copyable<has_lvalue_reference_member>);
109 static_assert(!std::copyable<has_rvalue_reference_member>);
110 static_assert(!std::copyable<has_function_ref_member>);
112 static_assert(
113 !std::assignable_from<deleted_assignment_from_const_rvalue&,
114 deleted_assignment_from_const_rvalue const>);
115 static_assert(!std::copyable<deleted_assignment_from_const_rvalue>);