xref: /aosp_15_r20/external/libcxx/include/compare (revision 58b9f456b02922dfdb1fad8a988d5fd8765ecb80)
1*58b9f456SAndroid Build Coastguard Worker// -*- C++ -*-
2*58b9f456SAndroid Build Coastguard Worker//===-------------------------- compare -----------------------------------===//
3*58b9f456SAndroid Build Coastguard Worker//
4*58b9f456SAndroid Build Coastguard Worker//                     The LLVM Compiler Infrastructure
5*58b9f456SAndroid Build Coastguard Worker//
6*58b9f456SAndroid Build Coastguard Worker// This file is dual licensed under the MIT and the University of Illinois Open
7*58b9f456SAndroid Build Coastguard Worker// Source Licenses. See LICENSE.TXT for details.
8*58b9f456SAndroid Build Coastguard Worker//
9*58b9f456SAndroid Build Coastguard Worker//===----------------------------------------------------------------------===//
10*58b9f456SAndroid Build Coastguard Worker
11*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_COMPARE
12*58b9f456SAndroid Build Coastguard Worker#define _LIBCPP_COMPARE
13*58b9f456SAndroid Build Coastguard Worker
14*58b9f456SAndroid Build Coastguard Worker/*
15*58b9f456SAndroid Build Coastguard Worker    compare synopsis
16*58b9f456SAndroid Build Coastguard Worker
17*58b9f456SAndroid Build Coastguard Workernamespace std {
18*58b9f456SAndroid Build Coastguard Worker  // [cmp.categories], comparison category types
19*58b9f456SAndroid Build Coastguard Worker  class weak_equality;
20*58b9f456SAndroid Build Coastguard Worker  class strong_equality;
21*58b9f456SAndroid Build Coastguard Worker  class partial_ordering;
22*58b9f456SAndroid Build Coastguard Worker  class weak_ordering;
23*58b9f456SAndroid Build Coastguard Worker  class strong_ordering;
24*58b9f456SAndroid Build Coastguard Worker
25*58b9f456SAndroid Build Coastguard Worker  // named comparison functions
26*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_eq  (weak_equality cmp) noexcept    { return cmp == 0; }
27*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_neq (weak_equality cmp) noexcept    { return cmp != 0; }
28*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_lt  (partial_ordering cmp) noexcept { return cmp < 0; }
29*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_lteq(partial_ordering cmp) noexcept { return cmp <= 0; }
30*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_gt  (partial_ordering cmp) noexcept { return cmp > 0; }
31*58b9f456SAndroid Build Coastguard Worker  constexpr bool is_gteq(partial_ordering cmp) noexcept { return cmp >= 0; }
32*58b9f456SAndroid Build Coastguard Worker
33*58b9f456SAndroid Build Coastguard Worker  // [cmp.common], common comparison category type
34*58b9f456SAndroid Build Coastguard Worker  template<class... Ts>
35*58b9f456SAndroid Build Coastguard Worker  struct common_comparison_category {
36*58b9f456SAndroid Build Coastguard Worker    using type = see below;
37*58b9f456SAndroid Build Coastguard Worker  };
38*58b9f456SAndroid Build Coastguard Worker  template<class... Ts>
39*58b9f456SAndroid Build Coastguard Worker    using common_comparison_category_t = typename common_comparison_category<Ts...>::type;
40*58b9f456SAndroid Build Coastguard Worker
41*58b9f456SAndroid Build Coastguard Worker  // [cmp.alg], comparison algorithms
42*58b9f456SAndroid Build Coastguard Worker  template<class T> constexpr strong_ordering strong_order(const T& a, const T& b);
43*58b9f456SAndroid Build Coastguard Worker  template<class T> constexpr weak_ordering weak_order(const T& a, const T& b);
44*58b9f456SAndroid Build Coastguard Worker  template<class T> constexpr partial_ordering partial_order(const T& a, const T& b);
45*58b9f456SAndroid Build Coastguard Worker  template<class T> constexpr strong_equality strong_equal(const T& a, const T& b);
46*58b9f456SAndroid Build Coastguard Worker  template<class T> constexpr weak_equality weak_equal(const T& a, const T& b);
47*58b9f456SAndroid Build Coastguard Worker}
48*58b9f456SAndroid Build Coastguard Worker*/
49*58b9f456SAndroid Build Coastguard Worker
50*58b9f456SAndroid Build Coastguard Worker#include <__config>
51*58b9f456SAndroid Build Coastguard Worker#include <type_traits>
52*58b9f456SAndroid Build Coastguard Worker#include <array>
53*58b9f456SAndroid Build Coastguard Worker
54*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
55*58b9f456SAndroid Build Coastguard Worker#pragma GCC system_header
56*58b9f456SAndroid Build Coastguard Worker#endif
57*58b9f456SAndroid Build Coastguard Worker
58*58b9f456SAndroid Build Coastguard Worker_LIBCPP_BEGIN_NAMESPACE_STD
59*58b9f456SAndroid Build Coastguard Worker
60*58b9f456SAndroid Build Coastguard Worker#if _LIBCPP_STD_VER > 17
61*58b9f456SAndroid Build Coastguard Worker
62*58b9f456SAndroid Build Coastguard Worker// exposition only
63*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS _EqResult : unsigned char {
64*58b9f456SAndroid Build Coastguard Worker  __zero = 0,
65*58b9f456SAndroid Build Coastguard Worker  __equal = __zero,
66*58b9f456SAndroid Build Coastguard Worker  __equiv = __equal,
67*58b9f456SAndroid Build Coastguard Worker  __nonequal = 1,
68*58b9f456SAndroid Build Coastguard Worker  __nonequiv = __nonequal
69*58b9f456SAndroid Build Coastguard Worker};
70*58b9f456SAndroid Build Coastguard Worker
71*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS _OrdResult : signed char {
72*58b9f456SAndroid Build Coastguard Worker  __less = -1,
73*58b9f456SAndroid Build Coastguard Worker  __greater = 1
74*58b9f456SAndroid Build Coastguard Worker};
75*58b9f456SAndroid Build Coastguard Worker
76*58b9f456SAndroid Build Coastguard Workerenum class _LIBCPP_ENUM_VIS _NCmpResult : signed char {
77*58b9f456SAndroid Build Coastguard Worker  __unordered = -127
78*58b9f456SAndroid Build Coastguard Worker};
79*58b9f456SAndroid Build Coastguard Worker
80*58b9f456SAndroid Build Coastguard Workerstruct _CmpUnspecifiedType;
81*58b9f456SAndroid Build Coastguard Workerusing _CmpUnspecifiedParam = void (_CmpUnspecifiedType::*)();
82*58b9f456SAndroid Build Coastguard Worker
83*58b9f456SAndroid Build Coastguard Workerclass  weak_equality {
84*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
85*58b9f456SAndroid Build Coastguard Worker  constexpr explicit weak_equality(_EqResult __val) noexcept : __value_(__val) {}
86*58b9f456SAndroid Build Coastguard Worker
87*58b9f456SAndroid Build Coastguard Workerpublic:
88*58b9f456SAndroid Build Coastguard Worker  static const weak_equality equivalent;
89*58b9f456SAndroid Build Coastguard Worker  static const weak_equality nonequivalent;
90*58b9f456SAndroid Build Coastguard Worker
91*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept;
92*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept;
93*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept;
94*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept;
95*58b9f456SAndroid Build Coastguard Worker
96*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
97*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept;
98*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept;
99*58b9f456SAndroid Build Coastguard Worker#endif
100*58b9f456SAndroid Build Coastguard Worker
101*58b9f456SAndroid Build Coastguard Workerprivate:
102*58b9f456SAndroid Build Coastguard Worker  _EqResult __value_;
103*58b9f456SAndroid Build Coastguard Worker};
104*58b9f456SAndroid Build Coastguard Worker
105*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::equivalent(_EqResult::__equiv);
106*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr weak_equality weak_equality::nonequivalent(_EqResult::__nonequiv);
107*58b9f456SAndroid Build Coastguard Worker
108*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
109*58b9f456SAndroid Build Coastguard Workerinline constexpr bool operator==(weak_equality __v, _CmpUnspecifiedParam) noexcept {
110*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == _EqResult::__zero;
111*58b9f456SAndroid Build Coastguard Worker}
112*58b9f456SAndroid Build Coastguard Worker
113*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
114*58b9f456SAndroid Build Coastguard Workerinline constexpr bool operator==(_CmpUnspecifiedParam, weak_equality __v) noexcept {
115*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == _EqResult::__zero;
116*58b9f456SAndroid Build Coastguard Worker}
117*58b9f456SAndroid Build Coastguard Worker
118*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
119*58b9f456SAndroid Build Coastguard Workerinline constexpr bool operator!=(weak_equality __v, _CmpUnspecifiedParam) noexcept {
120*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != _EqResult::__zero;
121*58b9f456SAndroid Build Coastguard Worker}
122*58b9f456SAndroid Build Coastguard Worker
123*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
124*58b9f456SAndroid Build Coastguard Workerinline constexpr bool operator!=(_CmpUnspecifiedParam, weak_equality __v) noexcept {
125*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != _EqResult::__zero;
126*58b9f456SAndroid Build Coastguard Worker}
127*58b9f456SAndroid Build Coastguard Worker
128*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
129*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
130*58b9f456SAndroid Build Coastguard Workerinline constexpr weak_equality operator<=>(weak_equality __v, _CmpUnspecifiedParam) noexcept {
131*58b9f456SAndroid Build Coastguard Worker  return __v;
132*58b9f456SAndroid Build Coastguard Worker}
133*58b9f456SAndroid Build Coastguard Worker
134*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
135*58b9f456SAndroid Build Coastguard Workerinline constexpr weak_equality operator<=>(_CmpUnspecifiedParam, weak_equality __v) noexcept {
136*58b9f456SAndroid Build Coastguard Worker  return __v;
137*58b9f456SAndroid Build Coastguard Worker}
138*58b9f456SAndroid Build Coastguard Worker#endif
139*58b9f456SAndroid Build Coastguard Worker
140*58b9f456SAndroid Build Coastguard Workerclass strong_equality {
141*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
142*58b9f456SAndroid Build Coastguard Worker  explicit constexpr strong_equality(_EqResult __val) noexcept : __value_(__val) {}
143*58b9f456SAndroid Build Coastguard Worker
144*58b9f456SAndroid Build Coastguard Workerpublic:
145*58b9f456SAndroid Build Coastguard Worker  static const strong_equality equal;
146*58b9f456SAndroid Build Coastguard Worker  static const strong_equality nonequal;
147*58b9f456SAndroid Build Coastguard Worker  static const strong_equality equivalent;
148*58b9f456SAndroid Build Coastguard Worker  static const strong_equality nonequivalent;
149*58b9f456SAndroid Build Coastguard Worker
150*58b9f456SAndroid Build Coastguard Worker  // conversion
151*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY constexpr operator weak_equality() const noexcept {
152*58b9f456SAndroid Build Coastguard Worker    return __value_ == _EqResult::__zero ? weak_equality::equivalent
153*58b9f456SAndroid Build Coastguard Worker          : weak_equality::nonequivalent;
154*58b9f456SAndroid Build Coastguard Worker  }
155*58b9f456SAndroid Build Coastguard Worker
156*58b9f456SAndroid Build Coastguard Worker  // comparisons
157*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept;
158*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept;
159*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept;
160*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept;
161*58b9f456SAndroid Build Coastguard Worker
162*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
163*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept;
164*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept;
165*58b9f456SAndroid Build Coastguard Worker#endif
166*58b9f456SAndroid Build Coastguard Workerprivate:
167*58b9f456SAndroid Build Coastguard Worker  _EqResult __value_;
168*58b9f456SAndroid Build Coastguard Worker};
169*58b9f456SAndroid Build Coastguard Worker
170*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equal(_EqResult::__equal);
171*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequal(_EqResult::__nonequal);
172*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::equivalent(_EqResult::__equiv);
173*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_equality strong_equality::nonequivalent(_EqResult::__nonequiv);
174*58b9f456SAndroid Build Coastguard Worker
175*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
176*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(strong_equality __v, _CmpUnspecifiedParam) noexcept {
177*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == _EqResult::__zero;
178*58b9f456SAndroid Build Coastguard Worker}
179*58b9f456SAndroid Build Coastguard Worker
180*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
181*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(_CmpUnspecifiedParam, strong_equality __v) noexcept {
182*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == _EqResult::__zero;
183*58b9f456SAndroid Build Coastguard Worker}
184*58b9f456SAndroid Build Coastguard Worker
185*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
186*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(strong_equality __v, _CmpUnspecifiedParam) noexcept {
187*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != _EqResult::__zero;
188*58b9f456SAndroid Build Coastguard Worker}
189*58b9f456SAndroid Build Coastguard Worker
190*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
191*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(_CmpUnspecifiedParam, strong_equality __v) noexcept {
192*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != _EqResult::__zero;
193*58b9f456SAndroid Build Coastguard Worker}
194*58b9f456SAndroid Build Coastguard Worker
195*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
196*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
197*58b9f456SAndroid Build Coastguard Workerconstexpr strong_equality operator<=>(strong_equality __v, _CmpUnspecifiedParam) noexcept {
198*58b9f456SAndroid Build Coastguard Worker  return __v;
199*58b9f456SAndroid Build Coastguard Worker}
200*58b9f456SAndroid Build Coastguard Worker
201*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
202*58b9f456SAndroid Build Coastguard Workerconstexpr strong_equality operator<=>(_CmpUnspecifiedParam, strong_equality __v) noexcept {
203*58b9f456SAndroid Build Coastguard Worker  return __v;
204*58b9f456SAndroid Build Coastguard Worker}
205*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
206*58b9f456SAndroid Build Coastguard Worker
207*58b9f456SAndroid Build Coastguard Workerclass partial_ordering {
208*58b9f456SAndroid Build Coastguard Worker  using _ValueT = signed char;
209*58b9f456SAndroid Build Coastguard Worker
210*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
211*58b9f456SAndroid Build Coastguard Worker  explicit constexpr partial_ordering(_EqResult __v) noexcept
212*58b9f456SAndroid Build Coastguard Worker      : __value_(_ValueT(__v)) {}
213*58b9f456SAndroid Build Coastguard Worker
214*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
215*58b9f456SAndroid Build Coastguard Worker  explicit constexpr partial_ordering(_OrdResult __v) noexcept
216*58b9f456SAndroid Build Coastguard Worker      : __value_(_ValueT(__v)) {}
217*58b9f456SAndroid Build Coastguard Worker
218*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
219*58b9f456SAndroid Build Coastguard Worker  explicit constexpr partial_ordering(_NCmpResult __v) noexcept
220*58b9f456SAndroid Build Coastguard Worker      : __value_(_ValueT(__v)) {}
221*58b9f456SAndroid Build Coastguard Worker
222*58b9f456SAndroid Build Coastguard Worker  constexpr bool __is_ordered() const noexcept {
223*58b9f456SAndroid Build Coastguard Worker    return __value_ != _ValueT(_NCmpResult::__unordered);
224*58b9f456SAndroid Build Coastguard Worker  }
225*58b9f456SAndroid Build Coastguard Workerpublic:
226*58b9f456SAndroid Build Coastguard Worker  // valid values
227*58b9f456SAndroid Build Coastguard Worker  static const partial_ordering less;
228*58b9f456SAndroid Build Coastguard Worker  static const partial_ordering equivalent;
229*58b9f456SAndroid Build Coastguard Worker  static const partial_ordering greater;
230*58b9f456SAndroid Build Coastguard Worker  static const partial_ordering unordered;
231*58b9f456SAndroid Build Coastguard Worker
232*58b9f456SAndroid Build Coastguard Worker  // conversion
233*58b9f456SAndroid Build Coastguard Worker  constexpr operator weak_equality() const noexcept {
234*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? weak_equality::equivalent : weak_equality::nonequivalent;
235*58b9f456SAndroid Build Coastguard Worker  }
236*58b9f456SAndroid Build Coastguard Worker
237*58b9f456SAndroid Build Coastguard Worker  // comparisons
238*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
239*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
240*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
241*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
242*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept;
243*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
244*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
245*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
246*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
247*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
248*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept;
249*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
250*58b9f456SAndroid Build Coastguard Worker
251*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
252*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept;
253*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept;
254*58b9f456SAndroid Build Coastguard Worker#endif
255*58b9f456SAndroid Build Coastguard Worker
256*58b9f456SAndroid Build Coastguard Workerprivate:
257*58b9f456SAndroid Build Coastguard Worker  _ValueT __value_;
258*58b9f456SAndroid Build Coastguard Worker};
259*58b9f456SAndroid Build Coastguard Worker
260*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::less(_OrdResult::__less);
261*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::equivalent(_EqResult::__equiv);
262*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater);
263*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered);
264*58b9f456SAndroid Build Coastguard Worker
265*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
266*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
267*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && __v.__value_ == 0;
268*58b9f456SAndroid Build Coastguard Worker}
269*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
270*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
271*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && __v.__value_ < 0;
272*58b9f456SAndroid Build Coastguard Worker}
273*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
274*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
275*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && __v.__value_ <= 0;
276*58b9f456SAndroid Build Coastguard Worker}
277*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
278*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept {
279*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && __v.__value_ > 0;
280*58b9f456SAndroid Build Coastguard Worker}
281*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
282*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
283*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && __v.__value_ >= 0;
284*58b9f456SAndroid Build Coastguard Worker}
285*58b9f456SAndroid Build Coastguard Worker
286*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
287*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
288*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && 0 == __v.__value_;
289*58b9f456SAndroid Build Coastguard Worker}
290*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
291*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
292*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && 0 < __v.__value_;
293*58b9f456SAndroid Build Coastguard Worker}
294*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
295*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
296*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && 0 <= __v.__value_;
297*58b9f456SAndroid Build Coastguard Worker}
298*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
299*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept {
300*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && 0 > __v.__value_;
301*58b9f456SAndroid Build Coastguard Worker}
302*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
303*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
304*58b9f456SAndroid Build Coastguard Worker  return __v.__is_ordered() && 0 >= __v.__value_;
305*58b9f456SAndroid Build Coastguard Worker}
306*58b9f456SAndroid Build Coastguard Worker
307*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
308*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
309*58b9f456SAndroid Build Coastguard Worker  return !__v.__is_ordered() || __v.__value_ != 0;
310*58b9f456SAndroid Build Coastguard Worker}
311*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
312*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
313*58b9f456SAndroid Build Coastguard Worker  return !__v.__is_ordered() || __v.__value_ != 0;
314*58b9f456SAndroid Build Coastguard Worker}
315*58b9f456SAndroid Build Coastguard Worker
316*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
317*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
318*58b9f456SAndroid Build Coastguard Workerconstexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
319*58b9f456SAndroid Build Coastguard Worker  return __v;
320*58b9f456SAndroid Build Coastguard Worker}
321*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
322*58b9f456SAndroid Build Coastguard Workerconstexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
323*58b9f456SAndroid Build Coastguard Worker  return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v);
324*58b9f456SAndroid Build Coastguard Worker}
325*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
326*58b9f456SAndroid Build Coastguard Worker
327*58b9f456SAndroid Build Coastguard Workerclass weak_ordering {
328*58b9f456SAndroid Build Coastguard Worker  using _ValueT = signed char;
329*58b9f456SAndroid Build Coastguard Worker
330*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
331*58b9f456SAndroid Build Coastguard Worker  explicit constexpr weak_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
332*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
333*58b9f456SAndroid Build Coastguard Worker  explicit constexpr weak_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
334*58b9f456SAndroid Build Coastguard Worker
335*58b9f456SAndroid Build Coastguard Workerpublic:
336*58b9f456SAndroid Build Coastguard Worker  static const weak_ordering less;
337*58b9f456SAndroid Build Coastguard Worker  static const weak_ordering equivalent;
338*58b9f456SAndroid Build Coastguard Worker  static const weak_ordering greater;
339*58b9f456SAndroid Build Coastguard Worker
340*58b9f456SAndroid Build Coastguard Worker  // conversions
341*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
342*58b9f456SAndroid Build Coastguard Worker  constexpr operator weak_equality() const noexcept {
343*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? weak_equality::equivalent
344*58b9f456SAndroid Build Coastguard Worker                         : weak_equality::nonequivalent;
345*58b9f456SAndroid Build Coastguard Worker  }
346*58b9f456SAndroid Build Coastguard Worker
347*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
348*58b9f456SAndroid Build Coastguard Worker  constexpr operator partial_ordering() const noexcept {
349*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? partial_ordering::equivalent
350*58b9f456SAndroid Build Coastguard Worker        : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
351*58b9f456SAndroid Build Coastguard Worker  }
352*58b9f456SAndroid Build Coastguard Worker
353*58b9f456SAndroid Build Coastguard Worker  // comparisons
354*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
355*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
356*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
357*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
358*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept;
359*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
360*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
361*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
362*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
363*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
364*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept;
365*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
366*58b9f456SAndroid Build Coastguard Worker
367*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
368*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept;
369*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept;
370*58b9f456SAndroid Build Coastguard Worker#endif
371*58b9f456SAndroid Build Coastguard Worker
372*58b9f456SAndroid Build Coastguard Workerprivate:
373*58b9f456SAndroid Build Coastguard Worker  _ValueT __value_;
374*58b9f456SAndroid Build Coastguard Worker};
375*58b9f456SAndroid Build Coastguard Worker
376*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less);
377*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv);
378*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater);
379*58b9f456SAndroid Build Coastguard Worker
380*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
381*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
382*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == 0;
383*58b9f456SAndroid Build Coastguard Worker}
384*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
385*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
386*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != 0;
387*58b9f456SAndroid Build Coastguard Worker}
388*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
389*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
390*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ < 0;
391*58b9f456SAndroid Build Coastguard Worker}
392*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
393*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
394*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ <= 0;
395*58b9f456SAndroid Build Coastguard Worker}
396*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
397*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept {
398*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ > 0;
399*58b9f456SAndroid Build Coastguard Worker}
400*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
401*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
402*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ >= 0;
403*58b9f456SAndroid Build Coastguard Worker}
404*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
405*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
406*58b9f456SAndroid Build Coastguard Worker  return 0 == __v.__value_;
407*58b9f456SAndroid Build Coastguard Worker}
408*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
409*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
410*58b9f456SAndroid Build Coastguard Worker  return 0 != __v.__value_;
411*58b9f456SAndroid Build Coastguard Worker}
412*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
413*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
414*58b9f456SAndroid Build Coastguard Worker  return 0 < __v.__value_;
415*58b9f456SAndroid Build Coastguard Worker}
416*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
417*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
418*58b9f456SAndroid Build Coastguard Worker  return 0 <= __v.__value_;
419*58b9f456SAndroid Build Coastguard Worker}
420*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
421*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept {
422*58b9f456SAndroid Build Coastguard Worker  return 0 > __v.__value_;
423*58b9f456SAndroid Build Coastguard Worker}
424*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
425*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
426*58b9f456SAndroid Build Coastguard Worker  return 0 >= __v.__value_;
427*58b9f456SAndroid Build Coastguard Worker}
428*58b9f456SAndroid Build Coastguard Worker
429*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
430*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
431*58b9f456SAndroid Build Coastguard Workerconstexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept {
432*58b9f456SAndroid Build Coastguard Worker  return __v;
433*58b9f456SAndroid Build Coastguard Worker}
434*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
435*58b9f456SAndroid Build Coastguard Workerconstexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept {
436*58b9f456SAndroid Build Coastguard Worker  return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v);
437*58b9f456SAndroid Build Coastguard Worker}
438*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
439*58b9f456SAndroid Build Coastguard Worker
440*58b9f456SAndroid Build Coastguard Workerclass strong_ordering {
441*58b9f456SAndroid Build Coastguard Worker  using _ValueT = signed char;
442*58b9f456SAndroid Build Coastguard Worker
443*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
444*58b9f456SAndroid Build Coastguard Worker  explicit constexpr strong_ordering(_EqResult __v) noexcept : __value_(_ValueT(__v)) {}
445*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
446*58b9f456SAndroid Build Coastguard Worker  explicit constexpr strong_ordering(_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
447*58b9f456SAndroid Build Coastguard Worker
448*58b9f456SAndroid Build Coastguard Workerpublic:
449*58b9f456SAndroid Build Coastguard Worker  static const strong_ordering less;
450*58b9f456SAndroid Build Coastguard Worker  static const strong_ordering equal;
451*58b9f456SAndroid Build Coastguard Worker  static const strong_ordering equivalent;
452*58b9f456SAndroid Build Coastguard Worker  static const strong_ordering greater;
453*58b9f456SAndroid Build Coastguard Worker
454*58b9f456SAndroid Build Coastguard Worker  // conversions
455*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
456*58b9f456SAndroid Build Coastguard Worker  constexpr operator weak_equality() const noexcept {
457*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? weak_equality::equivalent
458*58b9f456SAndroid Build Coastguard Worker                         : weak_equality::nonequivalent;
459*58b9f456SAndroid Build Coastguard Worker  }
460*58b9f456SAndroid Build Coastguard Worker
461*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
462*58b9f456SAndroid Build Coastguard Worker  constexpr operator strong_equality() const noexcept {
463*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? strong_equality::equal
464*58b9f456SAndroid Build Coastguard Worker                         : strong_equality::nonequal;
465*58b9f456SAndroid Build Coastguard Worker  }
466*58b9f456SAndroid Build Coastguard Worker
467*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
468*58b9f456SAndroid Build Coastguard Worker  constexpr operator partial_ordering() const noexcept {
469*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? partial_ordering::equivalent
470*58b9f456SAndroid Build Coastguard Worker        : (__value_ < 0 ? partial_ordering::less : partial_ordering::greater);
471*58b9f456SAndroid Build Coastguard Worker  }
472*58b9f456SAndroid Build Coastguard Worker
473*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY
474*58b9f456SAndroid Build Coastguard Worker  constexpr operator weak_ordering() const noexcept {
475*58b9f456SAndroid Build Coastguard Worker    return __value_ == 0 ? weak_ordering::equivalent
476*58b9f456SAndroid Build Coastguard Worker        : (__value_ < 0 ? weak_ordering::less : weak_ordering::greater);
477*58b9f456SAndroid Build Coastguard Worker  }
478*58b9f456SAndroid Build Coastguard Worker
479*58b9f456SAndroid Build Coastguard Worker  // comparisons
480*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
481*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
482*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
483*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
484*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept;
485*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
486*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
487*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
488*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
489*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
490*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept;
491*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
492*58b9f456SAndroid Build Coastguard Worker
493*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
494*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept;
495*58b9f456SAndroid Build Coastguard Worker  _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept;
496*58b9f456SAndroid Build Coastguard Worker#endif
497*58b9f456SAndroid Build Coastguard Worker
498*58b9f456SAndroid Build Coastguard Workerprivate:
499*58b9f456SAndroid Build Coastguard Worker  _ValueT __value_;
500*58b9f456SAndroid Build Coastguard Worker};
501*58b9f456SAndroid Build Coastguard Worker
502*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::less(_OrdResult::__less);
503*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equal(_EqResult::__equal);
504*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv);
505*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater);
506*58b9f456SAndroid Build Coastguard Worker
507*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
508*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
509*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ == 0;
510*58b9f456SAndroid Build Coastguard Worker}
511*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
512*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
513*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ != 0;
514*58b9f456SAndroid Build Coastguard Worker}
515*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
516*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
517*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ < 0;
518*58b9f456SAndroid Build Coastguard Worker}
519*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
520*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
521*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ <= 0;
522*58b9f456SAndroid Build Coastguard Worker}
523*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
524*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept {
525*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ > 0;
526*58b9f456SAndroid Build Coastguard Worker}
527*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
528*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
529*58b9f456SAndroid Build Coastguard Worker  return __v.__value_ >= 0;
530*58b9f456SAndroid Build Coastguard Worker}
531*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
532*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator==(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
533*58b9f456SAndroid Build Coastguard Worker  return 0 == __v.__value_;
534*58b9f456SAndroid Build Coastguard Worker}
535*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
536*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator!=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
537*58b9f456SAndroid Build Coastguard Worker  return 0 != __v.__value_;
538*58b9f456SAndroid Build Coastguard Worker}
539*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
540*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
541*58b9f456SAndroid Build Coastguard Worker  return 0 < __v.__value_;
542*58b9f456SAndroid Build Coastguard Worker}
543*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
544*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
545*58b9f456SAndroid Build Coastguard Worker  return 0 <= __v.__value_;
546*58b9f456SAndroid Build Coastguard Worker}
547*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
548*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept {
549*58b9f456SAndroid Build Coastguard Worker  return 0 > __v.__value_;
550*58b9f456SAndroid Build Coastguard Worker}
551*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
552*58b9f456SAndroid Build Coastguard Workerconstexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
553*58b9f456SAndroid Build Coastguard Worker  return 0 >= __v.__value_;
554*58b9f456SAndroid Build Coastguard Worker}
555*58b9f456SAndroid Build Coastguard Worker
556*58b9f456SAndroid Build Coastguard Worker#ifndef _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
557*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
558*58b9f456SAndroid Build Coastguard Workerconstexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept {
559*58b9f456SAndroid Build Coastguard Worker  return __v;
560*58b9f456SAndroid Build Coastguard Worker}
561*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
562*58b9f456SAndroid Build Coastguard Workerconstexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept {
563*58b9f456SAndroid Build Coastguard Worker  return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v);
564*58b9f456SAndroid Build Coastguard Worker}
565*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_HAS_NO_SPACESHIP_OPERATOR
566*58b9f456SAndroid Build Coastguard Worker
567*58b9f456SAndroid Build Coastguard Worker// named comparison functions
568*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
569*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_eq(weak_equality __cmp) noexcept    { return __cmp == 0; }
570*58b9f456SAndroid Build Coastguard Worker
571*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
572*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_neq(weak_equality __cmp) noexcept    { return __cmp != 0; }
573*58b9f456SAndroid Build Coastguard Worker
574*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
575*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }
576*58b9f456SAndroid Build Coastguard Worker
577*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
578*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_lteq(partial_ordering __cmp) noexcept { return __cmp <= 0; }
579*58b9f456SAndroid Build Coastguard Worker
580*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
581*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_gt(partial_ordering __cmp) noexcept { return __cmp > 0; }
582*58b9f456SAndroid Build Coastguard Worker
583*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
584*58b9f456SAndroid Build Coastguard Workerconstexpr bool is_gteq(partial_ordering __cmp) noexcept { return __cmp >= 0; }
585*58b9f456SAndroid Build Coastguard Worker
586*58b9f456SAndroid Build Coastguard Workernamespace __comp_detail {
587*58b9f456SAndroid Build Coastguard Worker
588*58b9f456SAndroid Build Coastguard Workerenum _ClassifyCompCategory : unsigned{
589*58b9f456SAndroid Build Coastguard Worker  _None,
590*58b9f456SAndroid Build Coastguard Worker  _WeakEq,
591*58b9f456SAndroid Build Coastguard Worker  _StrongEq,
592*58b9f456SAndroid Build Coastguard Worker  _PartialOrd,
593*58b9f456SAndroid Build Coastguard Worker  _WeakOrd,
594*58b9f456SAndroid Build Coastguard Worker  _StrongOrd,
595*58b9f456SAndroid Build Coastguard Worker  _CCC_Size
596*58b9f456SAndroid Build Coastguard Worker};
597*58b9f456SAndroid Build Coastguard Worker
598*58b9f456SAndroid Build Coastguard Workertemplate <class _Tp>
599*58b9f456SAndroid Build Coastguard Worker_LIBCPP_INLINE_VISIBILITY
600*58b9f456SAndroid Build Coastguard Workerconstexpr _ClassifyCompCategory __type_to_enum() noexcept {
601*58b9f456SAndroid Build Coastguard Worker  if (is_same_v<_Tp, weak_equality>)
602*58b9f456SAndroid Build Coastguard Worker    return _WeakEq;
603*58b9f456SAndroid Build Coastguard Worker  if (is_same_v<_Tp, strong_equality>)
604*58b9f456SAndroid Build Coastguard Worker    return _StrongEq;
605*58b9f456SAndroid Build Coastguard Worker  if (is_same_v<_Tp, partial_ordering>)
606*58b9f456SAndroid Build Coastguard Worker    return _PartialOrd;
607*58b9f456SAndroid Build Coastguard Worker  if (is_same_v<_Tp, weak_ordering>)
608*58b9f456SAndroid Build Coastguard Worker    return _WeakOrd;
609*58b9f456SAndroid Build Coastguard Worker  if (is_same_v<_Tp, strong_ordering>)
610*58b9f456SAndroid Build Coastguard Worker    return _StrongOrd;
611*58b9f456SAndroid Build Coastguard Worker  return _None;
612*58b9f456SAndroid Build Coastguard Worker}
613*58b9f456SAndroid Build Coastguard Worker
614*58b9f456SAndroid Build Coastguard Workertemplate <size_t _Size>
615*58b9f456SAndroid Build Coastguard Workerconstexpr _ClassifyCompCategory
616*58b9f456SAndroid Build Coastguard Worker__compute_comp_type(std::array<_ClassifyCompCategory, _Size> __types) {
617*58b9f456SAndroid Build Coastguard Worker  std::array<int, _CCC_Size> __seen = {};
618*58b9f456SAndroid Build Coastguard Worker  for (auto __type : __types)
619*58b9f456SAndroid Build Coastguard Worker    ++__seen[__type];
620*58b9f456SAndroid Build Coastguard Worker  if (__seen[_None])
621*58b9f456SAndroid Build Coastguard Worker    return _None;
622*58b9f456SAndroid Build Coastguard Worker  if (__seen[_WeakEq])
623*58b9f456SAndroid Build Coastguard Worker    return _WeakEq;
624*58b9f456SAndroid Build Coastguard Worker  if (__seen[_StrongEq] && (__seen[_PartialOrd] || __seen[_WeakOrd]))
625*58b9f456SAndroid Build Coastguard Worker    return _WeakEq;
626*58b9f456SAndroid Build Coastguard Worker  if (__seen[_StrongEq])
627*58b9f456SAndroid Build Coastguard Worker    return _StrongEq;
628*58b9f456SAndroid Build Coastguard Worker  if (__seen[_PartialOrd])
629*58b9f456SAndroid Build Coastguard Worker    return _PartialOrd;
630*58b9f456SAndroid Build Coastguard Worker  if (__seen[_WeakOrd])
631*58b9f456SAndroid Build Coastguard Worker    return _WeakOrd;
632*58b9f456SAndroid Build Coastguard Worker  return _StrongOrd;
633*58b9f456SAndroid Build Coastguard Worker}
634*58b9f456SAndroid Build Coastguard Worker
635*58b9f456SAndroid Build Coastguard Workertemplate <class ..._Ts>
636*58b9f456SAndroid Build Coastguard Workerconstexpr auto __get_comp_type() {
637*58b9f456SAndroid Build Coastguard Worker  using _CCC = _ClassifyCompCategory;
638*58b9f456SAndroid Build Coastguard Worker  constexpr array<_CCC, sizeof...(_Ts)> __type_kinds{{__comp_detail::__type_to_enum<_Ts>()...}};
639*58b9f456SAndroid Build Coastguard Worker  constexpr _CCC _Cat = sizeof...(_Ts) == 0 ? _StrongOrd
640*58b9f456SAndroid Build Coastguard Worker      : __compute_comp_type(__type_kinds);
641*58b9f456SAndroid Build Coastguard Worker  if constexpr (_Cat == _None)
642*58b9f456SAndroid Build Coastguard Worker    return void();
643*58b9f456SAndroid Build Coastguard Worker  else if constexpr (_Cat == _WeakEq)
644*58b9f456SAndroid Build Coastguard Worker    return weak_equality::equivalent;
645*58b9f456SAndroid Build Coastguard Worker  else if constexpr (_Cat == _StrongEq)
646*58b9f456SAndroid Build Coastguard Worker    return strong_equality::equivalent;
647*58b9f456SAndroid Build Coastguard Worker  else if constexpr (_Cat == _PartialOrd)
648*58b9f456SAndroid Build Coastguard Worker    return partial_ordering::equivalent;
649*58b9f456SAndroid Build Coastguard Worker  else if constexpr (_Cat == _WeakOrd)
650*58b9f456SAndroid Build Coastguard Worker    return weak_ordering::equivalent;
651*58b9f456SAndroid Build Coastguard Worker  else if constexpr (_Cat == _StrongOrd)
652*58b9f456SAndroid Build Coastguard Worker    return strong_ordering::equivalent;
653*58b9f456SAndroid Build Coastguard Worker  else
654*58b9f456SAndroid Build Coastguard Worker    static_assert(_Cat != _Cat, "unhandled case");
655*58b9f456SAndroid Build Coastguard Worker}
656*58b9f456SAndroid Build Coastguard Worker} // namespace __comp_detail
657*58b9f456SAndroid Build Coastguard Worker
658*58b9f456SAndroid Build Coastguard Worker// [cmp.common], common comparison category type
659*58b9f456SAndroid Build Coastguard Workertemplate<class... _Ts>
660*58b9f456SAndroid Build Coastguard Workerstruct _LIBCPP_TEMPLATE_VIS common_comparison_category {
661*58b9f456SAndroid Build Coastguard Worker  using type = decltype(__comp_detail::__get_comp_type<_Ts...>());
662*58b9f456SAndroid Build Coastguard Worker};
663*58b9f456SAndroid Build Coastguard Worker
664*58b9f456SAndroid Build Coastguard Workertemplate<class... _Ts>
665*58b9f456SAndroid Build Coastguard Workerusing common_comparison_category_t = typename common_comparison_category<_Ts...>::type;
666*58b9f456SAndroid Build Coastguard Worker
667*58b9f456SAndroid Build Coastguard Worker// [cmp.alg], comparison algorithms
668*58b9f456SAndroid Build Coastguard Worker// TODO: unimplemented
669*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp> constexpr strong_ordering strong_order(const _Tp& __lhs, const _Tp& __rhs);
670*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp> constexpr weak_ordering weak_order(const _Tp& __lhs, const _Tp& __rhs);
671*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp> constexpr partial_ordering partial_order(const _Tp& __lhs, const _Tp& __rhs);
672*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp> constexpr strong_equality strong_equal(const _Tp& __lhs, const _Tp& __rhs);
673*58b9f456SAndroid Build Coastguard Workertemplate<class _Tp> constexpr weak_equality weak_equal(const _Tp& __lhs, const _Tp& __rhs);
674*58b9f456SAndroid Build Coastguard Worker
675*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_STD_VER > 17
676*58b9f456SAndroid Build Coastguard Worker
677*58b9f456SAndroid Build Coastguard Worker_LIBCPP_END_NAMESPACE_STD
678*58b9f456SAndroid Build Coastguard Worker
679*58b9f456SAndroid Build Coastguard Worker#endif // _LIBCPP_COMPARE
680