Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / concepts / concepts.compare / concept.equalitycomparable / equality_comparable.compile.pass.cpp
blob126606ef7ab3cd3716860070108218ec2fa08d13
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 equality_comparable = // see below
14 #include <concepts>
16 #include <array>
17 #include <deque>
18 #include <forward_list>
19 #include <list>
20 #include <map>
21 #include <memory>
22 #include <optional>
23 #include <set>
24 #include <unordered_map>
25 #include <unordered_set>
26 #include <vector>
28 #include "compare_types.h"
30 namespace fundamentals {
31 static_assert(std::equality_comparable<int>);
32 static_assert(std::equality_comparable<double>);
33 static_assert(std::equality_comparable<void*>);
34 static_assert(std::equality_comparable<char*>);
35 static_assert(std::equality_comparable<char const*>);
36 static_assert(std::equality_comparable<char volatile*>);
37 static_assert(std::equality_comparable<char const volatile*>);
38 static_assert(std::equality_comparable<wchar_t&>);
39 static_assert(std::equality_comparable<char8_t const&>);
40 static_assert(std::equality_comparable<char16_t volatile&>);
41 static_assert(std::equality_comparable<char32_t const volatile&>);
42 static_assert(std::equality_comparable<unsigned char&&>);
43 static_assert(std::equality_comparable<unsigned short const&&>);
44 static_assert(std::equality_comparable<unsigned int volatile&&>);
45 static_assert(std::equality_comparable<unsigned long const volatile&&>);
46 static_assert(std::equality_comparable<int[5]>);
47 static_assert(std::equality_comparable<int (*)(int)>);
48 static_assert(std::equality_comparable<int (&)(int)>);
49 static_assert(std::equality_comparable<int (*)(int) noexcept>);
50 static_assert(std::equality_comparable<int (&)(int) noexcept>);
51 static_assert(std::equality_comparable<std::nullptr_t>);
53 struct S {};
54 static_assert(std::equality_comparable<int S::*>);
55 static_assert(std::equality_comparable<int (S::*)()>);
56 static_assert(std::equality_comparable<int (S::*)() noexcept>);
57 static_assert(std::equality_comparable<int (S::*)() &>);
58 static_assert(std::equality_comparable<int (S::*)() & noexcept>);
59 static_assert(std::equality_comparable<int (S::*)() &&>);
60 static_assert(std::equality_comparable<int (S::*)() && noexcept>);
61 static_assert(std::equality_comparable<int (S::*)() const>);
62 static_assert(std::equality_comparable<int (S::*)() const noexcept>);
63 static_assert(std::equality_comparable<int (S::*)() const&>);
64 static_assert(std::equality_comparable<int (S::*)() const & noexcept>);
65 static_assert(std::equality_comparable<int (S::*)() const&&>);
66 static_assert(std::equality_comparable<int (S::*)() const && noexcept>);
67 static_assert(std::equality_comparable<int (S::*)() volatile>);
68 static_assert(std::equality_comparable<int (S::*)() volatile noexcept>);
69 static_assert(std::equality_comparable<int (S::*)() volatile&>);
70 static_assert(std::equality_comparable<int (S::*)() volatile & noexcept>);
71 static_assert(std::equality_comparable<int (S::*)() volatile&&>);
72 static_assert(std::equality_comparable<int (S::*)() volatile && noexcept>);
73 static_assert(std::equality_comparable<int (S::*)() const volatile>);
74 static_assert(std::equality_comparable<int (S::*)() const volatile noexcept>);
75 static_assert(std::equality_comparable<int (S::*)() const volatile&>);
76 static_assert(std::equality_comparable<int (S::*)() const volatile & noexcept>);
77 static_assert(std::equality_comparable<int (S::*)() const volatile&&>);
78 static_assert(
79 std::equality_comparable<int (S::*)() const volatile && noexcept>);
81 static_assert(!std::equality_comparable<void>);
82 } // namespace fundamentals
84 namespace standard_types {
85 static_assert(std::equality_comparable<std::array<int, 10>>);
86 static_assert(std::equality_comparable<std::deque<int>>);
87 static_assert(std::equality_comparable<std::forward_list<int>>);
88 static_assert(std::equality_comparable<std::list<int>>);
89 static_assert(std::equality_comparable<std::map<int, void*>>);
90 static_assert(std::equality_comparable<std::optional<int>>);
91 static_assert(std::equality_comparable<std::set<int>>);
92 static_assert(std::equality_comparable<std::unordered_map<int, void*>>);
93 static_assert(std::equality_comparable<std::unordered_set<int>>);
94 static_assert(std::equality_comparable<std::vector<bool>>);
95 static_assert(std::equality_comparable<std::vector<int>>);
96 } // namespace standard_types
98 namespace types_fit_for_purpose {
99 static_assert(std::equality_comparable<cxx20_member_eq>);
100 static_assert(std::equality_comparable<cxx20_friend_eq>);
101 static_assert(std::equality_comparable<member_three_way_comparable>);
102 static_assert(std::equality_comparable<friend_three_way_comparable>);
103 static_assert(std::equality_comparable<explicit_operators>);
104 static_assert(std::equality_comparable<different_return_types>);
105 static_assert(std::equality_comparable<one_member_one_friend>);
106 static_assert(std::equality_comparable<equality_comparable_with_ec1>);
108 static_assert(!std::equality_comparable<no_eq>);
109 static_assert(!std::equality_comparable<no_neq>);
110 static_assert(std::equality_comparable<no_lt>);
111 static_assert(std::equality_comparable<no_gt>);
112 static_assert(std::equality_comparable<no_le>);
113 static_assert(std::equality_comparable<no_ge>);
115 static_assert(!std::equality_comparable<wrong_return_type_eq>);
116 static_assert(!std::equality_comparable<wrong_return_type_ne>);
117 static_assert(std::equality_comparable<wrong_return_type_lt>);
118 static_assert(std::equality_comparable<wrong_return_type_gt>);
119 static_assert(std::equality_comparable<wrong_return_type_le>);
120 static_assert(std::equality_comparable<wrong_return_type_ge>);
121 static_assert(!std::equality_comparable<wrong_return_type>);
122 static_assert(
123 !std::equality_comparable<cxx20_member_eq_operator_with_deleted_ne>);
124 static_assert(
125 !std::equality_comparable<cxx20_friend_eq_operator_with_deleted_ne>);
126 static_assert(
127 !std::equality_comparable<member_three_way_comparable_with_deleted_eq>);
128 static_assert(
129 !std::equality_comparable<member_three_way_comparable_with_deleted_ne>);
130 static_assert(
131 !std::equality_comparable<friend_three_way_comparable_with_deleted_eq>);
132 static_assert(
133 !std::equality_comparable<friend_three_way_comparable_with_deleted_ne>);
135 static_assert(!std::equality_comparable<eq_returns_explicit_bool>);
136 static_assert(!std::equality_comparable<ne_returns_explicit_bool>);
137 static_assert(std::equality_comparable<lt_returns_explicit_bool>);
138 static_assert(std::equality_comparable<gt_returns_explicit_bool>);
139 static_assert(std::equality_comparable<le_returns_explicit_bool>);
140 static_assert(std::equality_comparable<ge_returns_explicit_bool>);
141 static_assert(std::equality_comparable<returns_true_type>);
142 static_assert(std::equality_comparable<returns_int_ptr>);
143 } // namespace types_fit_for_purpose