34#pragma GCC system_header
37#define __glibcxx_want_three_way_comparison
40#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
44#pragma GCC diagnostic push
45#pragma GCC diagnostic ignored "-Wpedantic"
46#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
48namespace std _GLIBCXX_VISIBILITY(default)
54 using type =
signed char;
56 enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
58 enum class _Ncmp : type { _Unordered = 2 };
62 consteval __unspec(__unspec*)
noexcept { }
66 class partial_ordering
69 __cmp_cat::type _M_value;
72 partial_ordering(__cmp_cat::_Ord __v) noexcept
73 : _M_value(__cmp_cat::type(__v))
77 partial_ordering(__cmp_cat::_Ncmp __v) noexcept
78 : _M_value(__cmp_cat::type(__v))
81 friend class weak_ordering;
82 friend class strong_ordering;
86 static const partial_ordering less;
87 static const partial_ordering equivalent;
88 static const partial_ordering greater;
89 static const partial_ordering unordered;
94 operator==(partial_ordering __v, __cmp_cat::__unspec)
noexcept
95 {
return __v._M_value == 0; }
99 operator==(partial_ordering, partial_ordering)
noexcept =
default;
102 friend constexpr bool
103 operator< (partial_ordering __v, __cmp_cat::__unspec)
noexcept
104 {
return __v._M_value == -1; }
107 friend constexpr bool
108 operator> (partial_ordering __v, __cmp_cat::__unspec)
noexcept
109 {
return __v._M_value == 1; }
112 friend constexpr bool
113 operator<=(partial_ordering __v, __cmp_cat::__unspec)
noexcept
114 {
return __v._M_value <= 0; }
117 friend constexpr bool
118 operator>=(partial_ordering __v, __cmp_cat::__unspec)
noexcept
119 {
return __cmp_cat::type(__v._M_value & 1) == __v._M_value; }
122 friend constexpr bool
123 operator< (__cmp_cat::__unspec, partial_ordering __v)
noexcept
124 {
return __v._M_value == 1; }
127 friend constexpr bool
128 operator> (__cmp_cat::__unspec, partial_ordering __v)
noexcept
129 {
return __v._M_value == -1; }
132 friend constexpr bool
133 operator<=(__cmp_cat::__unspec, partial_ordering __v)
noexcept
134 {
return __cmp_cat::type(__v._M_value & 1) == __v._M_value; }
137 friend constexpr bool
138 operator>=(__cmp_cat::__unspec, partial_ordering __v)
noexcept
139 {
return 0 >= __v._M_value; }
142 friend constexpr partial_ordering
143 operator<=>(partial_ordering __v, __cmp_cat::__unspec)
noexcept
147 friend constexpr partial_ordering
148 operator<=>(__cmp_cat::__unspec, partial_ordering __v)
noexcept
150 if (__v._M_value & 1)
151 return partial_ordering(__cmp_cat::_Ord(-__v._M_value));
158 inline constexpr partial_ordering
159 partial_ordering::less(__cmp_cat::_Ord::less);
161 inline constexpr partial_ordering
162 partial_ordering::equivalent(__cmp_cat::_Ord::equivalent);
164 inline constexpr partial_ordering
165 partial_ordering::greater(__cmp_cat::_Ord::greater);
167 inline constexpr partial_ordering
168 partial_ordering::unordered(__cmp_cat::_Ncmp::_Unordered);
172 __cmp_cat::type _M_value;
175 weak_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(__cmp_cat::type(__v))
178 friend class strong_ordering;
182 static const weak_ordering less;
183 static const weak_ordering equivalent;
184 static const weak_ordering greater;
187 constexpr operator partial_ordering() const noexcept
188 {
return partial_ordering(__cmp_cat::_Ord(_M_value)); }
192 friend constexpr bool
193 operator==(weak_ordering __v, __cmp_cat::__unspec)
noexcept
194 {
return __v._M_value == 0; }
197 friend constexpr bool
198 operator==(weak_ordering, weak_ordering)
noexcept =
default;
201 friend constexpr bool
202 operator< (weak_ordering __v, __cmp_cat::__unspec)
noexcept
203 {
return __v._M_value < 0; }
206 friend constexpr bool
207 operator> (weak_ordering __v, __cmp_cat::__unspec)
noexcept
208 {
return __v._M_value > 0; }
211 friend constexpr bool
212 operator<=(weak_ordering __v, __cmp_cat::__unspec)
noexcept
213 {
return __v._M_value <= 0; }
216 friend constexpr bool
217 operator>=(weak_ordering __v, __cmp_cat::__unspec)
noexcept
218 {
return __v._M_value >= 0; }
221 friend constexpr bool
222 operator< (__cmp_cat::__unspec, weak_ordering __v)
noexcept
223 {
return 0 < __v._M_value; }
226 friend constexpr bool
227 operator> (__cmp_cat::__unspec, weak_ordering __v)
noexcept
228 {
return 0 > __v._M_value; }
231 friend constexpr bool
232 operator<=(__cmp_cat::__unspec, weak_ordering __v)
noexcept
233 {
return 0 <= __v._M_value; }
236 friend constexpr bool
237 operator>=(__cmp_cat::__unspec, weak_ordering __v)
noexcept
238 {
return 0 >= __v._M_value; }
241 friend constexpr weak_ordering
242 operator<=>(weak_ordering __v, __cmp_cat::__unspec)
noexcept
246 friend constexpr weak_ordering
247 operator<=>(__cmp_cat::__unspec, weak_ordering __v)
noexcept
248 {
return weak_ordering(__cmp_cat::_Ord(-__v._M_value)); }
252 inline constexpr weak_ordering
253 weak_ordering::less(__cmp_cat::_Ord::less);
255 inline constexpr weak_ordering
256 weak_ordering::equivalent(__cmp_cat::_Ord::equivalent);
258 inline constexpr weak_ordering
259 weak_ordering::greater(__cmp_cat::_Ord::greater);
261 class strong_ordering
263 __cmp_cat::type _M_value;
266 strong_ordering(__cmp_cat::_Ord __v) noexcept
267 : _M_value(__cmp_cat::type(__v))
272 static const strong_ordering less;
273 static const strong_ordering equal;
274 static const strong_ordering equivalent;
275 static const strong_ordering greater;
278 constexpr operator partial_ordering() const noexcept
279 {
return partial_ordering(__cmp_cat::_Ord(_M_value)); }
282 constexpr operator weak_ordering() const noexcept
283 {
return weak_ordering(__cmp_cat::_Ord(_M_value)); }
287 friend constexpr bool
288 operator==(strong_ordering __v, __cmp_cat::__unspec)
noexcept
289 {
return __v._M_value == 0; }
292 friend constexpr bool
293 operator==(strong_ordering, strong_ordering)
noexcept =
default;
296 friend constexpr bool
297 operator< (strong_ordering __v, __cmp_cat::__unspec)
noexcept
298 {
return __v._M_value < 0; }
301 friend constexpr bool
302 operator> (strong_ordering __v, __cmp_cat::__unspec)
noexcept
303 {
return __v._M_value > 0; }
306 friend constexpr bool
307 operator<=(strong_ordering __v, __cmp_cat::__unspec)
noexcept
308 {
return __v._M_value <= 0; }
311 friend constexpr bool
312 operator>=(strong_ordering __v, __cmp_cat::__unspec)
noexcept
313 {
return __v._M_value >= 0; }
316 friend constexpr bool
317 operator< (__cmp_cat::__unspec, strong_ordering __v)
noexcept
318 {
return 0 < __v._M_value; }
321 friend constexpr bool
322 operator> (__cmp_cat::__unspec, strong_ordering __v)
noexcept
323 {
return 0 > __v._M_value; }
326 friend constexpr bool
327 operator<=(__cmp_cat::__unspec, strong_ordering __v)
noexcept
328 {
return 0 <= __v._M_value; }
331 friend constexpr bool
332 operator>=(__cmp_cat::__unspec, strong_ordering __v)
noexcept
333 {
return 0 >= __v._M_value; }
336 friend constexpr strong_ordering
337 operator<=>(strong_ordering __v, __cmp_cat::__unspec)
noexcept
341 friend constexpr strong_ordering
342 operator<=>(__cmp_cat::__unspec, strong_ordering __v)
noexcept
343 {
return strong_ordering(__cmp_cat::_Ord(-__v._M_value)); }
347 inline constexpr strong_ordering
348 strong_ordering::less(__cmp_cat::_Ord::less);
350 inline constexpr strong_ordering
351 strong_ordering::equal(__cmp_cat::_Ord::equivalent);
353 inline constexpr strong_ordering
354 strong_ordering::equivalent(__cmp_cat::_Ord::equivalent);
356 inline constexpr strong_ordering
357 strong_ordering::greater(__cmp_cat::_Ord::greater);
363 is_eq(partial_ordering __cmp)
noexcept
364 {
return __cmp == 0; }
368 is_neq(partial_ordering __cmp)
noexcept
369 {
return __cmp != 0; }
373 is_lt (partial_ordering __cmp)
noexcept
374 {
return __cmp < 0; }
378 is_lteq(partial_ordering __cmp)
noexcept
379 {
return __cmp <= 0; }
383 is_gt (partial_ordering __cmp)
noexcept
384 {
return __cmp > 0; }
388 is_gteq(partial_ordering __cmp)
noexcept
389 {
return __cmp >= 0; }
393 template<
typename _Tp>
394 inline constexpr unsigned __cmp_cat_id = 1;
396 inline constexpr unsigned __cmp_cat_id<partial_ordering> = 2;
398 inline constexpr unsigned __cmp_cat_id<weak_ordering> = 4;
400 inline constexpr unsigned __cmp_cat_id<strong_ordering> = 8;
402 template<
typename... _Ts>
403 constexpr auto __common_cmp_cat()
405 constexpr unsigned __cats = (__cmp_cat_id<_Ts> | ...);
407 if constexpr (__cats & 1)
411 else if constexpr (bool(__cats & __cmp_cat_id<partial_ordering>))
412 return partial_ordering::equivalent;
415 else if constexpr (bool(__cats & __cmp_cat_id<weak_ordering>))
416 return weak_ordering::equivalent;
419 return strong_ordering::equivalent;
424 template<
typename... _Ts>
425 struct common_comparison_category
427 using type =
decltype(__detail::__common_cmp_cat<_Ts...>());
432 template<
typename _Tp>
433 struct common_comparison_category<_Tp>
434 {
using type = void; };
437 struct common_comparison_category<partial_ordering>
438 {
using type = partial_ordering; };
441 struct common_comparison_category<weak_ordering>
442 {
using type = weak_ordering; };
445 struct common_comparison_category<strong_ordering>
446 {
using type = strong_ordering; };
449 struct common_comparison_category<>
450 {
using type = strong_ordering; };
452 template<
typename... _Ts>
453 using common_comparison_category_t
454 =
typename common_comparison_category<_Ts...>::type;
456#if __cpp_lib_three_way_comparison >= 201907L
460 template<
typename _Tp,
typename _Cat>
461 concept __compares_as
462 = same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
466 template<
typename _Tp,
typename _Cat = partial_ordering>
467 concept three_way_comparable
468 = __detail::__weakly_eq_cmp_with<_Tp, _Tp>
469 && __detail::__partially_ordered_with<_Tp, _Tp>
473 { __a <=> __b } -> __detail::__compares_as<_Cat>;
476 template<
typename _Tp,
typename _Up,
typename _Cat = partial_ordering>
477 concept three_way_comparable_with
478 = three_way_comparable<_Tp, _Cat>
479 && three_way_comparable<_Up, _Cat>
480 && common_reference_with<const remove_reference_t<_Tp>&,
482 && three_way_comparable<
485 && __detail::__weakly_eq_cmp_with<_Tp, _Up>
486 && __detail::__partially_ordered_with<_Tp, _Up>
490 { __t <=> __u } -> __detail::__compares_as<_Cat>;
491 { __u <=> __t } -> __detail::__compares_as<_Cat>;
496 template<
typename _Tp,
typename _Up>
497 using __cmp3way_res_t
505 template<
typename _Tp,
typename _Up>
506 struct __cmp3way_res_impl
509 template<
typename _Tp,
typename _Up>
510 requires requires {
typename __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; }
511 struct __cmp3way_res_impl<_Tp, _Up>
513 using type = __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>;
518 template<
typename _Tp,
typename _Up = _Tp>
520 : __detail::__cmp3way_res_impl<_Tp, _Up>
524 template<
typename _Tp,
typename _Up = _Tp>
526 =
typename __detail::__cmp3way_res_impl<_Tp, _Up>::type;
534 template<
typename _Tp,
typename _Up>
535 concept __3way_builtin_ptr_cmp
536 =
requires(_Tp&& __t, _Up&& __u)
537 {
static_cast<_Tp&&
>(__t) <=>
static_cast<_Up&&
>(__u); }
538 && convertible_to<_Tp, const volatile void*>
539 && convertible_to<_Up, const volatile void*>
540 && __not_overloaded_spaceship<_Tp, _Up>;
547 struct compare_three_way
549 template<
typename _Tp,
typename _Up>
550 requires three_way_comparable_with<_Tp, _Up>
552 operator() [[nodiscard]] (_Tp&& __t, _Up&& __u)
const
555 if constexpr (__detail::__3way_builtin_ptr_cmp<_Tp, _Up>)
557 auto __pt =
static_cast<const volatile void*
>(__t);
558 auto __pu =
static_cast<const volatile void*
>(__u);
559 if (std::__is_constant_evaluated())
560 return __pt <=> __pu;
561 auto __it =
reinterpret_cast<__UINTPTR_TYPE__
>(__pt);
562 auto __iu =
reinterpret_cast<__UINTPTR_TYPE__
>(__pu);
563 return __it <=> __iu;
566 return static_cast<_Tp&&
>(__t) <=>
static_cast<_Up&&
>(__u);
569 using is_transparent = void;
576 template<
floating_po
int _Tp>
577 constexpr weak_ordering
578 __fp_weak_ordering(_Tp __e, _Tp __f)
582 auto __cat = [](_Tp __fp) ->
int {
583 const int __sign = __builtin_signbit(__fp) ? -1 : 1;
584 if (__builtin_isnormal(__fp))
585 return (__fp == 0 ? 1 : 3) * __sign;
586 if (__builtin_isnan(__fp))
588 if (
int __inf = __builtin_isinf_sign(__fp))
593 auto __po = __e <=> __f;
595 return weak_ordering::less;
596 else if (is_gt(__po))
597 return weak_ordering::greater;
598 else if (__po == partial_ordering::equivalent)
599 return weak_ordering::equivalent;
603 auto __isnan_sign = [](_Tp __fp) ->
int {
604 return __builtin_isnan(__fp)
605 ? __builtin_signbit(__fp) ? -1 : 1
608 auto __ord = __isnan_sign(__e) <=> __isnan_sign(__f);
610 return weak_ordering::equivalent;
611 else if (is_lt(__ord))
612 return weak_ordering::less;
614 return weak_ordering::greater;
618 void strong_order() =
delete;
620 template<
typename _Tp,
typename _Up>
621 concept __adl_strong =
requires(_Tp&& __t, _Up&& __u)
623 strong_ordering(strong_order(
static_cast<_Tp&&
>(__t),
624 static_cast<_Up&&
>(__u)));
627 void weak_order() =
delete;
629 template<
typename _Tp,
typename _Up>
630 concept __adl_weak =
requires(_Tp&& __t, _Up&& __u)
632 weak_ordering(weak_order(
static_cast<_Tp&&
>(__t),
633 static_cast<_Up&&
>(__u)));
636 void partial_order() =
delete;
638 template<
typename _Tp,
typename _Up>
639 concept __adl_partial =
requires(_Tp&& __t, _Up&& __u)
641 partial_ordering(partial_order(
static_cast<_Tp&&
>(__t),
642 static_cast<_Up&&
>(__u)));
645 template<
typename _Ord,
typename _Tp,
typename _Up>
646 concept __cmp3way =
requires(_Tp&& __t, _Up&& __u, compare_three_way __c)
648 _Ord(__c(
static_cast<_Tp&&
>(__t),
static_cast<_Up&&
>(__u)));
651 template<
typename _Tp,
typename _Up>
652 concept __strongly_ordered
653 = __adl_strong<_Tp, _Up>
654 || floating_point<remove_reference_t<_Tp>>
655 || __cmp3way<strong_ordering, _Tp, _Up>;
657 template<
typename _Tp,
typename _Up>
658 concept __decayed_same_as = same_as<decay_t<_Tp>, decay_t<_Up>>;
662 template<
typename _Tp,
typename _Up>
663 static constexpr bool
666 if constexpr (floating_point<decay_t<_Tp>>)
668 else if constexpr (__adl_strong<_Tp, _Up>)
671 else if constexpr (__cmp3way<strong_ordering, _Tp, _Up>)
676 friend class _Weak_order;
677 friend class _Strong_fallback;
682 _Binary16, _Binary32, _Binary64, _Binary128,
689#ifndef __cpp_using_enum
691 static constexpr _Fp_fmt _Binary16 = _Fp_fmt::_Binary16;
692 static constexpr _Fp_fmt _Binary32 = _Fp_fmt::_Binary32;
693 static constexpr _Fp_fmt _Binary64 = _Fp_fmt::_Binary64;
694 static constexpr _Fp_fmt _Binary128 = _Fp_fmt::_Binary128;
695 static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit;
696 static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit;
697 static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl;
698 static constexpr _Fp_fmt _Bfloat16 = _Fp_fmt::_Bfloat16;
702 template<
typename _Tp>
703 static consteval _Fp_fmt
706#ifdef __cpp_using_enum
713#ifdef __LONG_DOUBLE_IBM128__
714 if constexpr (__is_same(_Tp,
long double))
716#elif defined __LONG_DOUBLE_IEEE128__ && defined __SIZEOF_IBM128__
717 if constexpr (__is_same(_Tp, __ibm128))
721#if __LDBL_MANT_DIG__ == 64
722 if constexpr (__is_same(_Tp,
long double))
723 return __LDBL_MIN_EXP__ == -16381 ? _X86_80bit : _M68k_80bit;
725#ifdef __SIZEOF_FLOAT80__
726 if constexpr (__is_same(_Tp, __float80))
729#ifdef __STDCPP_BFLOAT16_T__
730 if constexpr (__is_same(_Tp,
decltype(0.0bf16)))
734 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
736 if constexpr (__width == 16)
738 else if constexpr (__width == 32)
740 else if constexpr (__width == 64)
742 else if constexpr (__width == 128)
747 using int64_t = __INT64_TYPE__;
748 using int32_t = __INT32_TYPE__;
749 using int16_t = __INT16_TYPE__;
750 using uint64_t = __UINT64_TYPE__;
751 using uint16_t = __UINT16_TYPE__;
754 template<
typename _Tp>
757#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
766 _Int(_Tp __hi, uint64_t __lo) noexcept : _M_hi(__hi)
770 _Int(uint64_t __lo) noexcept : _M_hi(0)
773 constexpr bool operator==(
const _Int&)
const =
default;
775#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
780 return _Int(
static_cast<_Tp
>(_M_lo << (__n - 64)), 0);
785 operator^=(
const _Int& __rhs)
noexcept
787 _M_hi ^= __rhs._M_hi;
788 _M_lo ^= __rhs._M_lo;
792 constexpr strong_ordering
793 operator<=>(
const _Int& __rhs)
const noexcept
795 strong_ordering __cmp = _M_hi <=> __rhs._M_hi;
796 if (__cmp != strong_ordering::equal)
798 return _M_lo <=> __rhs._M_lo;
802 template<
typename _Tp>
804 _S_compl(_Tp __t)
noexcept
806 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
808 make_unsigned_t<_Tp> __sign = __t >> (__width - 1);
811 return __t ^ (__sign >> 1);
815 template<
typename _Tp>
816 static constexpr _Int<_Tp>
817 _S_compl(_Int<_Tp> __t)
noexcept
819 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
820 make_unsigned_t<_Tp> __sign = __t._M_hi >> (__width - 1);
821 __t._M_hi ^= (__sign >> 1 );
822 uint64_t __sign64 = (_Tp)__sign;
823 __t._M_lo ^= __sign64;
828 template<
typename _Tp>
829 constexpr static auto
830 _S_fp_bits(_Tp __val)
noexcept
832 if constexpr (
sizeof(_Tp) ==
sizeof(int64_t))
833 return __builtin_bit_cast(int64_t, __val);
834 else if constexpr (
sizeof(_Tp) ==
sizeof(int32_t))
835 return __builtin_bit_cast(int32_t, __val);
836 else if constexpr (
sizeof(_Tp) ==
sizeof(int16_t))
837 return __builtin_bit_cast(int16_t, __val);
840#ifdef __cpp_using_enum
843 constexpr auto __fmt = _S_fp_fmt<_Tp>();
844 if constexpr (__fmt == _X86_80bit)
846 if constexpr (
sizeof(_Tp) == 3 *
sizeof(int32_t))
848 auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
849 return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
853 auto __ival = __builtin_bit_cast(_Int<int64_t>, __val);
854 return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
857 else if constexpr (__fmt == _M68k_80bit)
859 auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
860 return _Int<int16_t>(__ival._M_hi >> 16, __ival._M_lo);
862 else if constexpr (
sizeof(_Tp) == 2 *
sizeof(int64_t))
865 return __builtin_bit_cast(__int128, __val);
867 return __builtin_bit_cast(_Int<int64_t>, __val);
871 static_assert(
sizeof(_Tp) ==
sizeof(int64_t),
872 "unsupported floating-point type");
876 template<
typename _Tp>
877 static constexpr strong_ordering
878 _S_fp_cmp(_Tp __x, _Tp __y)
noexcept
881 if (__builtin_isnan(__x) || __builtin_isnan(__y))
883 int __ix = (bool) __builtin_isnan(__x);
884 int __iy = (bool) __builtin_isnan(__y);
885 __ix *= __builtin_signbit(__x) ? -1 : 1;
886 __iy *= __builtin_signbit(__y) ? -1 : 1;
887 return __ix <=> __iy;
890 return __builtin_bit_cast(strong_ordering, __x <=> __y);
893 auto __ix = _S_fp_bits(__x);
894 auto __iy = _S_fp_bits(__y);
897 return strong_ordering::equal;
899#ifdef __cpp_using_enum
902 constexpr auto __fmt = _S_fp_fmt<_Tp>();
904 if constexpr (__fmt == _Dbldbl)
908 struct _Unpacked {
double _M_hi; int64_t _M_lo; };
909 auto __x2 = __builtin_bit_cast(_Unpacked, __x);
910 auto __y2 = __builtin_bit_cast(_Unpacked, __y);
913 auto __cmp = _S_fp_cmp(__x2._M_hi, __y2._M_hi);
914 if (__cmp != strong_ordering::equal)
919 if (__builtin_isnan(__x2._M_hi))
920 return strong_ordering::equal;
923 if (((__x2._M_lo | __y2._M_lo) & 0x7fffffffffffffffULL) == 0)
924 return strong_ordering::equal;
927 return _S_compl(__x2._M_lo) <=> _S_compl(__y2._M_lo);
931 if constexpr (__fmt == _M68k_80bit)
936 constexpr uint16_t __maxexp = 0x7fff;
937 if ((__ix._M_hi & __maxexp) == __maxexp)
938 __ix._M_lo |= 1ull << 63;
939 if ((__iy._M_hi & __maxexp) == __maxexp)
940 __iy._M_lo |= 1ull << 63;
944#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
947 if (__builtin_isnan(__x) && __builtin_isnan(__y))
949 using _Int =
decltype(__ix);
951 constexpr int __nantype = __fmt == _Binary32 ? 22
952 : __fmt == _Binary64 ? 51
953 : __fmt == _Binary128 ? 111
955 constexpr _Int __bit = _Int(1) << __nantype;
961 return _S_compl(__ix) <=> _S_compl(__iy);
966 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
967 requires __strongly_ordered<_Tp, _Up>
968 constexpr strong_ordering
969 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
970 noexcept(_S_noexcept<_Tp, _Up>())
972 if constexpr (floating_point<decay_t<_Tp>>)
973 return _S_fp_cmp(__e, __f);
974 else if constexpr (__adl_strong<_Tp, _Up>)
975 return strong_ordering(strong_order(
static_cast<_Tp&&
>(__e),
976 static_cast<_Up&&
>(__f)));
977 else if constexpr (__cmp3way<strong_ordering, _Tp, _Up>)
978 return compare_three_way()(
static_cast<_Tp&&
>(__e),
979 static_cast<_Up&&
>(__f));
983 template<
typename _Tp,
typename _Up>
984 concept __weakly_ordered
985 = floating_point<remove_reference_t<_Tp>>
986 || __adl_weak<_Tp, _Up>
987 || __cmp3way<weak_ordering, _Tp, _Up>
988 || __strongly_ordered<_Tp, _Up>;
992 template<
typename _Tp,
typename _Up>
993 static constexpr bool
996 if constexpr (floating_point<decay_t<_Tp>>)
998 else if constexpr (__adl_weak<_Tp, _Up>)
1001 else if constexpr (__cmp3way<weak_ordering, _Tp, _Up>)
1004 else if constexpr (__strongly_ordered<_Tp, _Up>)
1005 return _Strong_order::_S_noexcept<_Tp, _Up>();
1008 friend class _Partial_order;
1009 friend class _Weak_fallback;
1012 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1013 requires __weakly_ordered<_Tp, _Up>
1014 constexpr weak_ordering
1015 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1016 noexcept(_S_noexcept<_Tp, _Up>())
1018 if constexpr (floating_point<decay_t<_Tp>>)
1019 return __compare::__fp_weak_ordering(__e, __f);
1020 else if constexpr (__adl_weak<_Tp, _Up>)
1021 return weak_ordering(weak_order(
static_cast<_Tp&&
>(__e),
1022 static_cast<_Up&&
>(__f)));
1023 else if constexpr (__cmp3way<weak_ordering, _Tp, _Up>)
1024 return compare_three_way()(
static_cast<_Tp&&
>(__e),
1025 static_cast<_Up&&
>(__f));
1026 else if constexpr (__strongly_ordered<_Tp, _Up>)
1027 return _Strong_order{}(
static_cast<_Tp&&
>(__e),
1028 static_cast<_Up&&
>(__f));
1032 template<
typename _Tp,
typename _Up>
1033 concept __partially_ordered
1034 = __adl_partial<_Tp, _Up>
1035 || __cmp3way<partial_ordering, _Tp, _Up>
1036 || __weakly_ordered<_Tp, _Up>;
1038 class _Partial_order
1040 template<
typename _Tp,
typename _Up>
1041 static constexpr bool
1044 if constexpr (__adl_partial<_Tp, _Up>)
1047 else if constexpr (__cmp3way<partial_ordering, _Tp, _Up>)
1050 else if constexpr (__weakly_ordered<_Tp, _Up>)
1051 return _Weak_order::_S_noexcept<_Tp, _Up>();
1054 friend class _Partial_fallback;
1057 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1058 requires __partially_ordered<_Tp, _Up>
1059 constexpr partial_ordering
1060 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1061 noexcept(_S_noexcept<_Tp, _Up>())
1063 if constexpr (__adl_partial<_Tp, _Up>)
1064 return partial_ordering(partial_order(
static_cast<_Tp&&
>(__e),
1065 static_cast<_Up&&
>(__f)));
1066 else if constexpr (__cmp3way<partial_ordering, _Tp, _Up>)
1067 return compare_three_way()(
static_cast<_Tp&&
>(__e),
1068 static_cast<_Up&&
>(__f));
1069 else if constexpr (__weakly_ordered<_Tp, _Up>)
1070 return _Weak_order{}(
static_cast<_Tp&&
>(__e),
1071 static_cast<_Up&&
>(__f));
1075 template<
typename _Tp,
typename _Up>
1076 concept __op_eq_lt =
requires(_Tp&& __t, _Up&& __u)
1078 {
static_cast<_Tp&&
>(__t) ==
static_cast<_Up&&
>(__u) }
1079 -> convertible_to<bool>;
1080 {
static_cast<_Tp&&
>(__t) <
static_cast<_Up&&
>(__u) }
1081 -> convertible_to<bool>;
1084 class _Strong_fallback
1086 template<
typename _Tp,
typename _Up>
1087 static constexpr bool
1090 if constexpr (__strongly_ordered<_Tp, _Up>)
1091 return _Strong_order::_S_noexcept<_Tp, _Up>();
1098 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1099 requires __strongly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up>
1100 constexpr strong_ordering
1101 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1102 noexcept(_S_noexcept<_Tp, _Up>())
1104 if constexpr (__strongly_ordered<_Tp, _Up>)
1105 return _Strong_order{}(
static_cast<_Tp&&
>(__e),
1106 static_cast<_Up&&
>(__f));
1108 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1109 ? strong_ordering::equal
1110 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1111 ? strong_ordering::less
1112 : strong_ordering::greater;
1116 class _Weak_fallback
1118 template<
typename _Tp,
typename _Up>
1119 static constexpr bool
1122 if constexpr (__weakly_ordered<_Tp, _Up>)
1123 return _Weak_order::_S_noexcept<_Tp, _Up>();
1130 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1131 requires __weakly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up>
1132 constexpr weak_ordering
1133 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1134 noexcept(_S_noexcept<_Tp, _Up>())
1136 if constexpr (__weakly_ordered<_Tp, _Up>)
1137 return _Weak_order{}(
static_cast<_Tp&&
>(__e),
1138 static_cast<_Up&&
>(__f));
1140 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1141 ? weak_ordering::equivalent
1142 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1143 ? weak_ordering::less
1144 : weak_ordering::greater;
1150 template<
typename _Tp,
typename _Up>
1151 concept __op_eq_lt_lt = __op_eq_lt<_Tp, _Up>
1152 &&
requires(_Tp&& __t, _Up&& __u)
1154 {
static_cast<_Up&&
>(__u) <
static_cast<_Tp&&
>(__t) }
1155 -> convertible_to<bool>;
1158 class _Partial_fallback
1160 template<
typename _Tp,
typename _Up>
1161 static constexpr bool
1164 if constexpr (__partially_ordered<_Tp, _Up>)
1165 return _Partial_order::_S_noexcept<_Tp, _Up>();
1172 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1173 requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up>
1174 constexpr partial_ordering
1175 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1176 noexcept(_S_noexcept<_Tp, _Up>())
1178 if constexpr (__partially_ordered<_Tp, _Up>)
1179 return _Partial_order{}(
static_cast<_Tp&&
>(__e),
1180 static_cast<_Up&&
>(__f));
1182 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1183 ? partial_ordering::equivalent
1184 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1185 ? partial_ordering::less
1186 :
static_cast<_Up&&
>(__f) <
static_cast<_Tp&&
>(__e)
1187 ? partial_ordering::greater
1188 : partial_ordering::unordered;
1195 inline namespace _Cpo
1197 inline constexpr __compare::_Strong_order strong_order{};
1199 inline constexpr __compare::_Weak_order weak_order{};
1201 inline constexpr __compare::_Partial_order partial_order{};
1203 inline constexpr __compare::_Strong_fallback
1204 compare_strong_order_fallback{};
1206 inline constexpr __compare::_Weak_fallback
1207 compare_weak_order_fallback{};
1209 inline constexpr __compare::_Partial_fallback
1210 compare_partial_order_fallback{};
1217 inline constexpr struct _Synth3way
1219 template<
typename _Tp,
typename _Up>
1220 static constexpr bool
1221 _S_noexcept(
const _Tp* __t =
nullptr,
const _Up* __u =
nullptr)
1223 if constexpr (three_way_comparable_with<_Tp, _Up>)
1224 return noexcept(*__t <=> *__u);
1226 return noexcept(*__t < *__u) &&
noexcept(*__u < *__t);
1229 template<
typename _Tp,
typename _Up>
1232 operator()(
const _Tp& __t,
const _Up& __u)
const
1233 noexcept(_S_noexcept<_Tp, _Up>())
1236 { __t < __u } -> __boolean_testable;
1237 { __u < __t } -> __boolean_testable;
1240 if constexpr (three_way_comparable_with<_Tp, _Up>)
1245 return weak_ordering::less;
1247 return weak_ordering::greater;
1249 return weak_ordering::equivalent;
1255 template<
typename _Tp,
typename _Up = _Tp>
1264#pragma GCC diagnostic pop
typename common_reference< _Tp... >::type common_reference_t
typename remove_reference< _Tp >::type remove_reference_t
Alias template for remove_reference.
auto declval() noexcept -> decltype(__declval< _Tp >(0))
ISO C++ entities toplevel namespace is std.
typename __detail::__cmp3way_res_impl< _Tp, _Up >::type compare_three_way_result_t
[cmp.result], result of three-way comparison
std::basic_ostream< _CharT, _Traits > & operator<<(std::basic_ostream< _CharT, _Traits > &__os, const bitset< _Nb > &__x)
Global I/O operators for bitsets.
Implementation details not part of the namespace std interface.
[cmp.result], result of three-way comparison