[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / PCH / Inputs / std-compare.h
blobeaf7951edf79c49df18200d62a236a40e91529e3
1 #ifndef STD_COMPARE_H
2 #define STD_COMPARE_H
4 namespace std {
5 inline namespace __1 {
7 // exposition only
8 enum class _EqResult : unsigned char {
9 __equal = 0,
10 __equiv = __equal,
13 enum class _OrdResult : signed char {
14 __less = -1,
15 __greater = 1
18 enum class _NCmpResult : signed char {
19 __unordered = -127
22 struct _CmpUnspecifiedType;
23 using _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
25 class partial_ordering {
26 using _ValueT = signed char;
27 explicit constexpr partial_ordering(_EqResult __v) noexcept
28 : __value_(_ValueT(__v)) {}
29 explicit constexpr partial_ordering(_OrdResult __v) noexcept
30 : __value_(_ValueT(__v)) {}
31 explicit constexpr partial_ordering(_NCmpResult __v) noexcept
32 : __value_(_ValueT(__v)) {}
34 constexpr bool __is_ordered() const noexcept {
35 return __value_ != _ValueT(_NCmpResult::__unordered);
38 public:
39 // valid values
40 static const partial_ordering less;
41 static const partial_ordering equivalent;
42 static const partial_ordering greater;
43 static const partial_ordering unordered;
45 // comparisons
46 friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
47 friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
48 friend constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
49 friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
50 friend constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
51 friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
52 friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
53 friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
54 friend constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
55 friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
56 friend constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
57 friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
59 friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
60 friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
62 // test helper
63 constexpr bool test_eq(partial_ordering const &other) const noexcept {
64 return __value_ == other.__value_;
67 private:
68 _ValueT __value_;
71 inline constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
72 inline constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
73 inline constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
74 inline constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
75 constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
76 return __v.__is_ordered() && __v.__value_ == 0;
78 constexpr bool operator<(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
79 return __v.__is_ordered() && __v.__value_ < 0;
81 constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
82 return __v.__is_ordered() && __v.__value_ <= 0;
84 constexpr bool operator>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
85 return __v.__is_ordered() && __v.__value_ > 0;
87 constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
88 return __v.__is_ordered() && __v.__value_ >= 0;
90 constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
91 return __v.__is_ordered() && 0 == __v.__value_;
93 constexpr bool operator<(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
94 return __v.__is_ordered() && 0 < __v.__value_;
96 constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
97 return __v.__is_ordered() && 0 <= __v.__value_;
99 constexpr bool operator>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
100 return __v.__is_ordered() && 0 > __v.__value_;
102 constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
103 return __v.__is_ordered() && 0 >= __v.__value_;
105 constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
106 return !__v.__is_ordered() || __v.__value_ != 0;
108 constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
109 return !__v.__is_ordered() || __v.__value_ != 0;
112 constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
113 return __v;
115 constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
116 return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
119 class weak_ordering {
120 using _ValueT = signed char;
121 explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
122 explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
124 public:
125 static const weak_ordering less;
126 static const weak_ordering equivalent;
127 static const weak_ordering greater;
129 // conversions
130 constexpr operator partial_ordering() const noexcept {
131 return __value_ == 0 ? partial_ordering::equivalent
132 : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
135 // comparisons
136 friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
137 friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
138 friend constexpr bool operator<(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
139 friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
140 friend constexpr bool operator>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
141 friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
142 friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
143 friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
144 friend constexpr bool operator<(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
145 friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
146 friend constexpr bool operator>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
147 friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
149 friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
150 friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
152 // test helper
153 constexpr bool test_eq(weak_ordering const &other) const noexcept {
154 return __value_ == other.__value_;
157 private:
158 _ValueT __value_;
161 inline constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
162 inline constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
163 inline constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
164 constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
165 return __v.__value_ == 0;
167 constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
168 return __v.__value_ != 0;
170 constexpr bool operator<(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
171 return __v.__value_ < 0;
173 constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
174 return __v.__value_ <= 0;
176 constexpr bool operator>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
177 return __v.__value_ > 0;
179 constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
180 return __v.__value_ >= 0;
182 constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
183 return 0 == __v.__value_;
185 constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
186 return 0 != __v.__value_;
188 constexpr bool operator<(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
189 return 0 < __v.__value_;
191 constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
192 return 0 <= __v.__value_;
194 constexpr bool operator>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
195 return 0 > __v.__value_;
197 constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
198 return 0 >= __v.__value_;
201 constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
202 return __v;
204 constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
205 return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
208 class strong_ordering {
209 using _ValueT = signed char;
210 explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(static_cast<signed char>(__v)) {}
211 explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(static_cast<signed char>(__v)) {}
213 public:
214 static const strong_ordering less;
215 static const strong_ordering equal;
216 static const strong_ordering equivalent;
217 static const strong_ordering greater;
219 // conversions
220 constexpr operator partial_ordering() const noexcept {
221 return __value_ == 0 ? partial_ordering::equivalent
222 : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
224 constexpr operator weak_ordering() const noexcept {
225 return __value_ == 0 ? weak_ordering::equivalent
226 : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
229 // comparisons
230 friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
231 friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
232 friend constexpr bool operator<(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
233 friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
234 friend constexpr bool operator>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
235 friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
236 friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
237 friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
238 friend constexpr bool operator<(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
239 friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
240 friend constexpr bool operator>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
241 friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
243 friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
244 friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
246 // test helper
247 constexpr bool test_eq(strong_ordering const &other) const noexcept {
248 return __value_ == other.__value_;
251 private:
252 _ValueT __value_;
255 inline constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
256 inline constexpr strong_ordering strong_ordering::equal(_EqResult::__equal);
257 inline constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
258 inline constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
260 constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
261 return __v.__value_ == 0;
263 constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
264 return __v.__value_ != 0;
266 constexpr bool operator<(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
267 return __v.__value_ < 0;
269 constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
270 return __v.__value_ <= 0;
272 constexpr bool operator>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
273 return __v.__value_ > 0;
275 constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
276 return __v.__value_ >= 0;
278 constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
279 return 0 == __v.__value_;
281 constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
282 return 0 != __v.__value_;
284 constexpr bool operator<(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
285 return 0 < __v.__value_;
287 constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
288 return 0 <= __v.__value_;
290 constexpr bool operator>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
291 return 0 > __v.__value_;
293 constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
294 return 0 >= __v.__value_;
297 constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
298 return __v;
300 constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
301 return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
304 } // namespace __1
305 } // end namespace std
307 #endif // STD_COMPARE_H