34#pragma GCC system_header
37#define __glibcxx_want_concepts
38#define __glibcxx_want_three_way_comparison
39#define __glibcxx_want_type_order
42#if __cplusplus > 201703L && __cpp_impl_three_way_comparison >= 201907L
46#pragma GCC diagnostic push
47#pragma GCC diagnostic ignored "-Wpedantic"
48#pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
50namespace std _GLIBCXX_VISIBILITY(default)
56 using type =
signed char;
58 enum class _Ord : type
60 equivalent = 0, less = -1, greater = 1,
62 unordered = -__SCHAR_MAX__ - 1
65 template<
typename _Ordering>
66 [[__gnu__::__always_inline__]]
68 __ord(_Ordering __o)
noexcept
69 {
return _Ord(__o._M_value); }
71 template<
typename _Ordering>
72 [[__gnu__::__always_inline__]]
74 __make(_Ord __o)
noexcept
75 {
return _Ordering(__o); }
79 consteval __literal_zero(__literal_zero*)
noexcept { }
83 class partial_ordering
86 __cmp_cat::type _M_value;
89 partial_ordering(__cmp_cat::_Ord __v) noexcept
90 : _M_value(__cmp_cat::type(__v))
93 [[__gnu__::__always_inline__]]
94 constexpr __cmp_cat::type
98 return static_cast<__cmp_cat::type
>(-_M_value);
101 friend constexpr __cmp_cat::_Ord
102 __cmp_cat::__ord<partial_ordering>(partial_ordering)
noexcept;
103 friend constexpr partial_ordering
104 __cmp_cat::__make<partial_ordering>(__cmp_cat::_Ord)
noexcept;
108 static const partial_ordering less;
109 static const partial_ordering equivalent;
110 static const partial_ordering greater;
111 static const partial_ordering unordered;
115 friend constexpr bool
116 operator==(partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
117 {
return __v._M_value == 0; }
120 friend constexpr bool
121 operator==(partial_ordering, partial_ordering)
noexcept =
default;
124 friend constexpr bool
125 operator< (partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
126 {
return __v._M_value == -1; }
129 friend constexpr bool
130 operator> (partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
131 {
return __v._M_value == 1; }
134 friend constexpr bool
135 operator<=(partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
136 {
return __v._M_reverse() >= 0; }
139 friend constexpr bool
140 operator>=(partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
141 {
return __v._M_value >= 0; }
144 friend constexpr bool
145 operator< (__cmp_cat::__literal_zero, partial_ordering __v)
noexcept
146 {
return __v._M_value == 1; }
149 friend constexpr bool
150 operator> (__cmp_cat::__literal_zero, partial_ordering __v)
noexcept
151 {
return __v._M_value == -1; }
154 friend constexpr bool
155 operator<=(__cmp_cat::__literal_zero, partial_ordering __v)
noexcept
156 {
return 0 <= __v._M_value; }
159 friend constexpr bool
160 operator>=(__cmp_cat::__literal_zero, partial_ordering __v)
noexcept
161 {
return 0 <= __v._M_reverse(); }
164 friend constexpr partial_ordering
165 operator<=>(partial_ordering __v, __cmp_cat::__literal_zero)
noexcept
169 friend constexpr partial_ordering
170 operator<=>(__cmp_cat::__literal_zero, partial_ordering __v)
noexcept
171 {
return partial_ordering(__cmp_cat::_Ord(__v._M_reverse())); }
175 inline constexpr partial_ordering
176 partial_ordering::less(__cmp_cat::_Ord::less);
178 inline constexpr partial_ordering
179 partial_ordering::equivalent(__cmp_cat::_Ord::equivalent);
181 inline constexpr partial_ordering
182 partial_ordering::greater(__cmp_cat::_Ord::greater);
184 inline constexpr partial_ordering
185 partial_ordering::unordered(__cmp_cat::_Ord::unordered);
189 __cmp_cat::type _M_value;
192 weak_ordering(__cmp_cat::_Ord __v) noexcept : _M_value(__cmp_cat::type(__v))
195 friend constexpr __cmp_cat::_Ord
196 __cmp_cat::__ord<weak_ordering>(weak_ordering)
noexcept;
197 friend constexpr weak_ordering
198 __cmp_cat::__make<weak_ordering>(__cmp_cat::_Ord)
noexcept;
202 static const weak_ordering less;
203 static const weak_ordering equivalent;
204 static const weak_ordering greater;
207 constexpr operator partial_ordering() const noexcept
208 {
return __cmp_cat::__make<partial_ordering>(__cmp_cat::_Ord(_M_value)); }
212 friend constexpr bool
213 operator==(weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
214 {
return __v._M_value == 0; }
217 friend constexpr bool
218 operator==(weak_ordering, weak_ordering)
noexcept =
default;
221 friend constexpr bool
222 operator< (weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
223 {
return __v._M_value < 0; }
226 friend constexpr bool
227 operator> (weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
228 {
return __v._M_value > 0; }
231 friend constexpr bool
232 operator<=(weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
233 {
return __v._M_value <= 0; }
236 friend constexpr bool
237 operator>=(weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
238 {
return __v._M_value >= 0; }
241 friend constexpr bool
242 operator< (__cmp_cat::__literal_zero, weak_ordering __v)
noexcept
243 {
return 0 < __v._M_value; }
246 friend constexpr bool
247 operator> (__cmp_cat::__literal_zero, weak_ordering __v)
noexcept
248 {
return 0 > __v._M_value; }
251 friend constexpr bool
252 operator<=(__cmp_cat::__literal_zero, weak_ordering __v)
noexcept
253 {
return 0 <= __v._M_value; }
256 friend constexpr bool
257 operator>=(__cmp_cat::__literal_zero, weak_ordering __v)
noexcept
258 {
return 0 >= __v._M_value; }
261 friend constexpr weak_ordering
262 operator<=>(weak_ordering __v, __cmp_cat::__literal_zero)
noexcept
266 friend constexpr weak_ordering
267 operator<=>(__cmp_cat::__literal_zero, weak_ordering __v)
noexcept
268 {
return weak_ordering(__cmp_cat::_Ord(-__v._M_value)); }
272 inline constexpr weak_ordering
273 weak_ordering::less(__cmp_cat::_Ord::less);
275 inline constexpr weak_ordering
276 weak_ordering::equivalent(__cmp_cat::_Ord::equivalent);
278 inline constexpr weak_ordering
279 weak_ordering::greater(__cmp_cat::_Ord::greater);
281 class strong_ordering
283 __cmp_cat::type _M_value;
286 strong_ordering(__cmp_cat::_Ord __v) noexcept
287 : _M_value(__cmp_cat::type(__v))
290 friend constexpr __cmp_cat::_Ord
291 __cmp_cat::__ord<strong_ordering>(strong_ordering)
noexcept;
292 friend constexpr strong_ordering
293 __cmp_cat::__make<strong_ordering>(__cmp_cat::_Ord)
noexcept;
297 static const strong_ordering less;
298 static const strong_ordering equal;
299 static const strong_ordering equivalent;
300 static const strong_ordering greater;
303 constexpr operator partial_ordering() const noexcept
304 {
return __cmp_cat::__make<partial_ordering>(__cmp_cat::_Ord(_M_value)); }
307 constexpr operator weak_ordering() const noexcept
308 {
return __cmp_cat::__make<weak_ordering>(__cmp_cat::_Ord(_M_value)); }
312 friend constexpr bool
313 operator==(strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
314 {
return __v._M_value == 0; }
317 friend constexpr bool
318 operator==(strong_ordering, strong_ordering)
noexcept =
default;
321 friend constexpr bool
322 operator< (strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
323 {
return __v._M_value < 0; }
326 friend constexpr bool
327 operator> (strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
328 {
return __v._M_value > 0; }
331 friend constexpr bool
332 operator<=(strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
333 {
return __v._M_value <= 0; }
336 friend constexpr bool
337 operator>=(strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
338 {
return __v._M_value >= 0; }
341 friend constexpr bool
342 operator< (__cmp_cat::__literal_zero, strong_ordering __v)
noexcept
343 {
return 0 < __v._M_value; }
346 friend constexpr bool
347 operator> (__cmp_cat::__literal_zero, strong_ordering __v)
noexcept
348 {
return 0 > __v._M_value; }
351 friend constexpr bool
352 operator<=(__cmp_cat::__literal_zero, strong_ordering __v)
noexcept
353 {
return 0 <= __v._M_value; }
356 friend constexpr bool
357 operator>=(__cmp_cat::__literal_zero, strong_ordering __v)
noexcept
358 {
return 0 >= __v._M_value; }
361 friend constexpr strong_ordering
362 operator<=>(strong_ordering __v, __cmp_cat::__literal_zero)
noexcept
366 friend constexpr strong_ordering
367 operator<=>(__cmp_cat::__literal_zero, strong_ordering __v)
noexcept
368 {
return strong_ordering(__cmp_cat::_Ord(-__v._M_value)); }
372 inline constexpr strong_ordering
373 strong_ordering::less(__cmp_cat::_Ord::less);
375 inline constexpr strong_ordering
376 strong_ordering::equal(__cmp_cat::_Ord::equivalent);
378 inline constexpr strong_ordering
379 strong_ordering::equivalent(__cmp_cat::_Ord::equivalent);
381 inline constexpr strong_ordering
382 strong_ordering::greater(__cmp_cat::_Ord::greater);
388 is_eq(partial_ordering __cmp)
noexcept
389 {
return __cmp == 0; }
393 is_neq(partial_ordering __cmp)
noexcept
394 {
return __cmp != 0; }
398 is_lt (partial_ordering __cmp)
noexcept
399 {
return __cmp < 0; }
403 is_lteq(partial_ordering __cmp)
noexcept
404 {
return __cmp <= 0; }
408 is_gt (partial_ordering __cmp)
noexcept
409 {
return __cmp > 0; }
413 is_gteq(partial_ordering __cmp)
noexcept
414 {
return __cmp >= 0; }
418 template<
typename _Tp>
419 inline constexpr unsigned __cmp_cat_id = 1;
421 inline constexpr unsigned __cmp_cat_id<partial_ordering> = 2;
423 inline constexpr unsigned __cmp_cat_id<weak_ordering> = 4;
425 inline constexpr unsigned __cmp_cat_id<strong_ordering> = 8;
427 template<
typename... _Ts>
428 constexpr auto __common_cmp_cat()
430 constexpr unsigned __cats = (__cmp_cat_id<_Ts> | ...);
432 if constexpr (__cats & 1)
436 else if constexpr (bool(__cats & __cmp_cat_id<partial_ordering>))
437 return partial_ordering::equivalent;
440 else if constexpr (bool(__cats & __cmp_cat_id<weak_ordering>))
441 return weak_ordering::equivalent;
444 return strong_ordering::equivalent;
449 template<
typename... _Ts>
450 struct common_comparison_category
452 using type =
decltype(__detail::__common_cmp_cat<_Ts...>());
457 template<
typename _Tp>
458 struct common_comparison_category<_Tp>
459 {
using type = void; };
462 struct common_comparison_category<partial_ordering>
463 {
using type = partial_ordering; };
466 struct common_comparison_category<weak_ordering>
467 {
using type = weak_ordering; };
470 struct common_comparison_category<strong_ordering>
471 {
using type = strong_ordering; };
474 struct common_comparison_category<>
475 {
using type = strong_ordering; };
477 template<
typename... _Ts>
478 using common_comparison_category_t
479 =
typename common_comparison_category<_Ts...>::type;
481#if __cpp_lib_three_way_comparison >= 201907L
485 template<
typename _Tp,
typename _Cat>
486 concept __compares_as
487 = same_as<common_comparison_category_t<_Tp, _Cat>, _Cat>;
491 template<
typename _Tp,
typename _Cat = partial_ordering>
492 concept three_way_comparable
493 = __detail::__weakly_eq_cmp_with<_Tp, _Tp>
494 && __detail::__partially_ordered_with<_Tp, _Tp>
498 { __a <=> __b } -> __detail::__compares_as<_Cat>;
501 template<
typename _Tp,
typename _Up,
typename _Cat = partial_ordering>
502 concept three_way_comparable_with
503 = three_way_comparable<_Tp, _Cat> && three_way_comparable<_Up, _Cat>
504 && __detail::__comparison_common_type_with<_Tp, _Up>
505 && three_way_comparable<
508 && __detail::__weakly_eq_cmp_with<_Tp, _Up>
509 && __detail::__partially_ordered_with<_Tp, _Up>
513 { __t <=> __u } -> __detail::__compares_as<_Cat>;
514 { __u <=> __t } -> __detail::__compares_as<_Cat>;
519 template<
typename _Tp,
typename _Up>
520 using __cmp3way_res_t
528 template<
typename _Tp,
typename _Up>
529 struct __cmp3way_res_impl
532 template<
typename _Tp,
typename _Up>
533 requires requires {
typename __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>; }
534 struct __cmp3way_res_impl<_Tp, _Up>
536 using type = __cmp3way_res_t<__cref<_Tp>, __cref<_Up>>;
541 template<
typename _Tp,
typename _Up = _Tp>
543 : __detail::__cmp3way_res_impl<_Tp, _Up>
547 template<
typename _Tp,
typename _Up = _Tp>
549 =
typename __detail::__cmp3way_res_impl<_Tp, _Up>::type;
557 template<
typename _Tp,
typename _Up>
558 concept __3way_builtin_ptr_cmp
559 =
requires(_Tp&& __t, _Up&& __u)
560 {
static_cast<_Tp&&
>(__t) <=>
static_cast<_Up&&
>(__u); }
563 && !
requires(_Tp&& __t, _Up&& __u)
564 { operator<=>(
static_cast<_Tp&&
>(__t),
static_cast<_Up&&
>(__u)); }
565 && !
requires(_Tp&& __t, _Up&& __u)
566 {
static_cast<_Tp&&
>(__t).operator<=>(
static_cast<_Up&&
>(__u)); };
573 struct compare_three_way
575#pragma GCC diagnostic push
576#pragma GCC diagnostic ignored "-Wc++23-extensions"
577 template<
typename _Tp,
typename _Up>
578 requires three_way_comparable_with<_Tp, _Up>
579 static constexpr auto
580 operator() [[nodiscard]] (_Tp&& __t, _Up&& __u)
583 if constexpr (__detail::__3way_builtin_ptr_cmp<_Tp, _Up>)
585 auto __pt =
static_cast<const volatile void*
>(__t);
586 auto __pu =
static_cast<const volatile void*
>(__u);
587 if (std::__is_constant_evaluated())
588 return __pt <=> __pu;
589 auto __it =
reinterpret_cast<__UINTPTR_TYPE__
>(__pt);
590 auto __iu =
reinterpret_cast<__UINTPTR_TYPE__
>(__pu);
591 return __it <=> __iu;
594 return static_cast<_Tp&&
>(__t) <=>
static_cast<_Up&&
>(__u);
596#pragma GCC diagnostic pop
598 using is_transparent = void;
605 template<
floating_po
int _Tp>
606 constexpr weak_ordering
607 __fp_weak_ordering(_Tp __e, _Tp __f)
609 auto __po = __cmp_cat::__ord(__e <=> __f);
610 if (__po != __cmp_cat::_Ord::unordered)
611 return __cmp_cat::__make<weak_ordering>(__po);
615 auto __isnan_sign = [](_Tp __fp) ->
int {
616 return __builtin_isnan(__fp)
617 ? __builtin_signbit(__fp) ? -1 : 1
620 return __isnan_sign(__e) <=> __isnan_sign(__f);
624 void strong_order() =
delete;
626 template<
typename _Tp,
typename _Up>
627 concept __adl_strong =
requires(_Tp&& __t, _Up&& __u)
629 strong_ordering(strong_order(
static_cast<_Tp&&
>(__t),
630 static_cast<_Up&&
>(__u)));
633 void weak_order() =
delete;
635 template<
typename _Tp,
typename _Up>
636 concept __adl_weak =
requires(_Tp&& __t, _Up&& __u)
638 weak_ordering(weak_order(
static_cast<_Tp&&
>(__t),
639 static_cast<_Up&&
>(__u)));
642 void partial_order() =
delete;
644 template<
typename _Tp,
typename _Up>
645 concept __adl_partial =
requires(_Tp&& __t, _Up&& __u)
647 partial_ordering(partial_order(
static_cast<_Tp&&
>(__t),
648 static_cast<_Up&&
>(__u)));
651 template<
typename _Ord,
typename _Tp,
typename _Up>
652 concept __cmp3way =
requires(_Tp&& __t, _Up&& __u, compare_three_way __c)
654 _Ord(__c(
static_cast<_Tp&&
>(__t),
static_cast<_Up&&
>(__u)));
657 template<
typename _Tp,
typename _Up>
658 concept __strongly_ordered
659 = __adl_strong<_Tp, _Up>
660 || floating_point<remove_reference_t<_Tp>>
661 || __cmp3way<strong_ordering, _Tp, _Up>;
663 template<
typename _Tp,
typename _Up>
664 concept __decayed_same_as = same_as<decay_t<_Tp>, decay_t<_Up>>;
668 template<
typename _Tp,
typename _Up>
669 static constexpr bool
672 if constexpr (floating_point<decay_t<_Tp>>)
674 else if constexpr (__adl_strong<_Tp, _Up>)
677 else if constexpr (__cmp3way<strong_ordering, _Tp, _Up>)
682 friend class _Weak_order;
683 friend class _Strong_fallback;
688 _Binary16, _Binary32, _Binary64, _Binary128,
695#ifndef __cpp_using_enum
697 static constexpr _Fp_fmt _Binary16 = _Fp_fmt::_Binary16;
698 static constexpr _Fp_fmt _Binary32 = _Fp_fmt::_Binary32;
699 static constexpr _Fp_fmt _Binary64 = _Fp_fmt::_Binary64;
700 static constexpr _Fp_fmt _Binary128 = _Fp_fmt::_Binary128;
701 static constexpr _Fp_fmt _X86_80bit = _Fp_fmt::_X86_80bit;
702 static constexpr _Fp_fmt _M68k_80bit = _Fp_fmt::_M68k_80bit;
703 static constexpr _Fp_fmt _Dbldbl = _Fp_fmt::_Dbldbl;
704 static constexpr _Fp_fmt _Bfloat16 = _Fp_fmt::_Bfloat16;
708 template<
typename _Tp>
709 static consteval _Fp_fmt
712#ifdef __cpp_using_enum
719#ifdef __LONG_DOUBLE_IBM128__
720 if constexpr (__is_same(_Tp,
long double))
722#elif defined __LONG_DOUBLE_IEEE128__ && defined __SIZEOF_IBM128__
723 if constexpr (__is_same(_Tp, __ibm128))
727#if __LDBL_MANT_DIG__ == 64
728 if constexpr (__is_same(_Tp,
long double))
729 return __LDBL_MIN_EXP__ == -16381 ? _X86_80bit : _M68k_80bit;
731#ifdef __SIZEOF_FLOAT80__
732 if constexpr (__is_same(_Tp, __float80))
735#ifdef __STDCPP_BFLOAT16_T__
736 if constexpr (__is_same(_Tp,
decltype(0.0bf16)))
740 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
742 if constexpr (__width == 16)
744 else if constexpr (__width == 32)
746 else if constexpr (__width == 64)
748 else if constexpr (__width == 128)
753 using int64_t = __INT64_TYPE__;
754 using int32_t = __INT32_TYPE__;
755 using int16_t = __INT16_TYPE__;
756 using uint64_t = __UINT64_TYPE__;
757 using uint16_t = __UINT16_TYPE__;
760 template<
typename _Tp>
763#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
772 _Int(_Tp __hi, uint64_t __lo) noexcept : _M_hi(__hi)
776 _Int(uint64_t __lo) noexcept : _M_hi(0)
779 constexpr bool operator==(
const _Int&)
const =
default;
781#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
786 return _Int(
static_cast<_Tp
>(_M_lo << (__n - 64)), 0);
791 operator^=(
const _Int& __rhs)
noexcept
793 _M_hi ^= __rhs._M_hi;
794 _M_lo ^= __rhs._M_lo;
798 constexpr strong_ordering
799 operator<=>(
const _Int& __rhs)
const noexcept
801 strong_ordering __cmp = _M_hi <=> __rhs._M_hi;
802 if (__cmp != strong_ordering::equal)
804 return _M_lo <=> __rhs._M_lo;
808 template<
typename _Tp>
810 _S_compl(_Tp __t)
noexcept
812 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
814 make_unsigned_t<_Tp> __sign = __t >> (__width - 1);
817 return __t ^ (__sign >> 1);
821 template<
typename _Tp>
822 static constexpr _Int<_Tp>
823 _S_compl(_Int<_Tp> __t)
noexcept
825 constexpr int __width =
sizeof(_Tp) * __CHAR_BIT__;
826 make_unsigned_t<_Tp> __sign = __t._M_hi >> (__width - 1);
827 __t._M_hi ^= (__sign >> 1 );
828 uint64_t __sign64 = (_Tp)__sign;
829 __t._M_lo ^= __sign64;
834 template<
typename _Tp>
835 constexpr static auto
836 _S_fp_bits(_Tp __val)
noexcept
838 if constexpr (
sizeof(_Tp) ==
sizeof(int64_t))
839 return __builtin_bit_cast(int64_t, __val);
840 else if constexpr (
sizeof(_Tp) ==
sizeof(int32_t))
841 return __builtin_bit_cast(int32_t, __val);
842 else if constexpr (
sizeof(_Tp) ==
sizeof(int16_t))
843 return __builtin_bit_cast(int16_t, __val);
846#ifdef __cpp_using_enum
849 constexpr auto __fmt = _S_fp_fmt<_Tp>();
850 if constexpr (__fmt == _X86_80bit)
852 if constexpr (
sizeof(_Tp) == 3 *
sizeof(int32_t))
854 auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
855 return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
859 auto __ival = __builtin_bit_cast(_Int<int64_t>, __val);
860 return _Int<int16_t>(__ival._M_hi, __ival._M_lo);
863 else if constexpr (__fmt == _M68k_80bit)
865 auto __ival = __builtin_bit_cast(_Int<int32_t>, __val);
866 return _Int<int16_t>(__ival._M_hi >> 16, __ival._M_lo);
868 else if constexpr (
sizeof(_Tp) == 2 *
sizeof(int64_t))
871 return __builtin_bit_cast(__int128, __val);
873 return __builtin_bit_cast(_Int<int64_t>, __val);
877 static_assert(
sizeof(_Tp) ==
sizeof(int64_t),
878 "unsupported floating-point type");
882 template<
typename _Tp>
883 static constexpr strong_ordering
884 _S_fp_cmp(_Tp __x, _Tp __y)
noexcept
887 if (__builtin_isnan(__x) || __builtin_isnan(__y))
889 int __ix = (bool) __builtin_isnan(__x);
890 int __iy = (bool) __builtin_isnan(__y);
891 __ix *= __builtin_signbit(__x) ? -1 : 1;
892 __iy *= __builtin_signbit(__y) ? -1 : 1;
893 return __ix <=> __iy;
896 return __builtin_bit_cast(strong_ordering, __x <=> __y);
899 auto __ix = _S_fp_bits(__x);
900 auto __iy = _S_fp_bits(__y);
903 return strong_ordering::equal;
905#ifdef __cpp_using_enum
908 constexpr auto __fmt = _S_fp_fmt<_Tp>();
910 if constexpr (__fmt == _Dbldbl)
914 struct _Unpacked {
double _M_hi; int64_t _M_lo; };
915 auto __x2 = __builtin_bit_cast(_Unpacked, __x);
916 auto __y2 = __builtin_bit_cast(_Unpacked, __y);
919 auto __cmp = _S_fp_cmp(__x2._M_hi, __y2._M_hi);
920 if (__cmp != strong_ordering::equal)
925 if (__builtin_isnan(__x2._M_hi))
926 return strong_ordering::equal;
929 if (((__x2._M_lo | __y2._M_lo) & 0x7fffffffffffffffULL) == 0)
930 return strong_ordering::equal;
933 return _S_compl(__x2._M_lo) <=> _S_compl(__y2._M_lo);
937 if constexpr (__fmt == _M68k_80bit)
942 constexpr uint16_t __maxexp = 0x7fff;
943 if ((__ix._M_hi & __maxexp) == __maxexp)
944 __ix._M_lo |= 1ull << 63;
945 if ((__iy._M_hi & __maxexp) == __maxexp)
946 __iy._M_lo |= 1ull << 63;
950#if defined __hppa__ || (defined __mips__ && !defined __mips_nan2008)
953 if (__builtin_isnan(__x) && __builtin_isnan(__y))
955 using _Int =
decltype(__ix);
957 constexpr int __nantype = __fmt == _Binary32 ? 22
958 : __fmt == _Binary64 ? 51
959 : __fmt == _Binary128 ? 111
961 constexpr _Int __bit = _Int(1) << __nantype;
967 return _S_compl(__ix) <=> _S_compl(__iy);
972 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
973 requires __strongly_ordered<_Tp, _Up>
974 constexpr strong_ordering
975 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
976 noexcept(_S_noexcept<_Tp, _Up>())
978 if constexpr (floating_point<decay_t<_Tp>>)
979 return _S_fp_cmp(__e, __f);
980 else if constexpr (__adl_strong<_Tp, _Up>)
981 return strong_ordering(strong_order(
static_cast<_Tp&&
>(__e),
982 static_cast<_Up&&
>(__f)));
983 else if constexpr (__cmp3way<strong_ordering, _Tp, _Up>)
984 return compare_three_way()(
static_cast<_Tp&&
>(__e),
985 static_cast<_Up&&
>(__f));
989 template<
typename _Tp,
typename _Up>
990 concept __weakly_ordered
991 = floating_point<remove_reference_t<_Tp>>
992 || __adl_weak<_Tp, _Up>
993 || __cmp3way<weak_ordering, _Tp, _Up>
994 || __strongly_ordered<_Tp, _Up>;
998 template<
typename _Tp,
typename _Up>
999 static constexpr bool
1002 if constexpr (floating_point<decay_t<_Tp>>)
1004 else if constexpr (__adl_weak<_Tp, _Up>)
1007 else if constexpr (__cmp3way<weak_ordering, _Tp, _Up>)
1010 else if constexpr (__strongly_ordered<_Tp, _Up>)
1011 return _Strong_order::_S_noexcept<_Tp, _Up>();
1014 friend class _Partial_order;
1015 friend class _Weak_fallback;
1018 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1019 requires __weakly_ordered<_Tp, _Up>
1020 constexpr weak_ordering
1021 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1022 noexcept(_S_noexcept<_Tp, _Up>())
1024 if constexpr (floating_point<decay_t<_Tp>>)
1025 return __compare::__fp_weak_ordering(__e, __f);
1026 else if constexpr (__adl_weak<_Tp, _Up>)
1027 return weak_ordering(weak_order(
static_cast<_Tp&&
>(__e),
1028 static_cast<_Up&&
>(__f)));
1029 else if constexpr (__cmp3way<weak_ordering, _Tp, _Up>)
1030 return compare_three_way()(
static_cast<_Tp&&
>(__e),
1031 static_cast<_Up&&
>(__f));
1032 else if constexpr (__strongly_ordered<_Tp, _Up>)
1033 return _Strong_order{}(
static_cast<_Tp&&
>(__e),
1034 static_cast<_Up&&
>(__f));
1038 template<
typename _Tp,
typename _Up>
1039 concept __partially_ordered
1040 = __adl_partial<_Tp, _Up>
1041 || __cmp3way<partial_ordering, _Tp, _Up>
1042 || __weakly_ordered<_Tp, _Up>;
1044 class _Partial_order
1046 template<
typename _Tp,
typename _Up>
1047 static constexpr bool
1050 if constexpr (__adl_partial<_Tp, _Up>)
1053 else if constexpr (__cmp3way<partial_ordering, _Tp, _Up>)
1056 else if constexpr (__weakly_ordered<_Tp, _Up>)
1057 return _Weak_order::_S_noexcept<_Tp, _Up>();
1060 friend class _Partial_fallback;
1063 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1064 requires __partially_ordered<_Tp, _Up>
1065 constexpr partial_ordering
1066 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1067 noexcept(_S_noexcept<_Tp, _Up>())
1069 if constexpr (__adl_partial<_Tp, _Up>)
1070 return partial_ordering(partial_order(
static_cast<_Tp&&
>(__e),
1071 static_cast<_Up&&
>(__f)));
1072 else if constexpr (__cmp3way<partial_ordering, _Tp, _Up>)
1073 return compare_three_way()(
static_cast<_Tp&&
>(__e),
1074 static_cast<_Up&&
>(__f));
1075 else if constexpr (__weakly_ordered<_Tp, _Up>)
1076 return _Weak_order{}(
static_cast<_Tp&&
>(__e),
1077 static_cast<_Up&&
>(__f));
1081 template<
typename _Tp,
typename _Up>
1082 concept __op_eq_lt =
requires(_Tp&& __t, _Up&& __u)
1084 {
static_cast<_Tp&&
>(__t) ==
static_cast<_Up&&
>(__u) }
1085 -> convertible_to<bool>;
1086 {
static_cast<_Tp&&
>(__t) <
static_cast<_Up&&
>(__u) }
1087 -> convertible_to<bool>;
1090 class _Strong_fallback
1092 template<
typename _Tp,
typename _Up>
1093 static constexpr bool
1096 if constexpr (__strongly_ordered<_Tp, _Up>)
1097 return _Strong_order::_S_noexcept<_Tp, _Up>();
1104 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1105 requires __strongly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up>
1106 constexpr strong_ordering
1107 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1108 noexcept(_S_noexcept<_Tp, _Up>())
1110 if constexpr (__strongly_ordered<_Tp, _Up>)
1111 return _Strong_order{}(
static_cast<_Tp&&
>(__e),
1112 static_cast<_Up&&
>(__f));
1114 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1115 ? strong_ordering::equal
1116 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1117 ? strong_ordering::less
1118 : strong_ordering::greater;
1122 class _Weak_fallback
1124 template<
typename _Tp,
typename _Up>
1125 static constexpr bool
1128 if constexpr (__weakly_ordered<_Tp, _Up>)
1129 return _Weak_order::_S_noexcept<_Tp, _Up>();
1136 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1137 requires __weakly_ordered<_Tp, _Up> || __op_eq_lt<_Tp, _Up>
1138 constexpr weak_ordering
1139 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1140 noexcept(_S_noexcept<_Tp, _Up>())
1142 if constexpr (__weakly_ordered<_Tp, _Up>)
1143 return _Weak_order{}(
static_cast<_Tp&&
>(__e),
1144 static_cast<_Up&&
>(__f));
1146 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1147 ? weak_ordering::equivalent
1148 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1149 ? weak_ordering::less
1150 : weak_ordering::greater;
1156 template<
typename _Tp,
typename _Up>
1157 concept __op_eq_lt_lt = __op_eq_lt<_Tp, _Up>
1158 &&
requires(_Tp&& __t, _Up&& __u)
1160 {
static_cast<_Up&&
>(__u) <
static_cast<_Tp&&
>(__t) }
1161 -> convertible_to<bool>;
1164 class _Partial_fallback
1166 template<
typename _Tp,
typename _Up>
1167 static constexpr bool
1170 if constexpr (__partially_ordered<_Tp, _Up>)
1171 return _Partial_order::_S_noexcept<_Tp, _Up>();
1178 template<
typename _Tp, __decayed_same_as<_Tp> _Up>
1179 requires __partially_ordered<_Tp, _Up> || __op_eq_lt_lt<_Tp, _Up>
1180 constexpr partial_ordering
1181 operator() [[nodiscard]] (_Tp&& __e, _Up&& __f)
const
1182 noexcept(_S_noexcept<_Tp, _Up>())
1184 if constexpr (__partially_ordered<_Tp, _Up>)
1185 return _Partial_order{}(
static_cast<_Tp&&
>(__e),
1186 static_cast<_Up&&
>(__f));
1188 return static_cast<_Tp&&
>(__e) ==
static_cast<_Up&&
>(__f)
1189 ? partial_ordering::equivalent
1190 :
static_cast<_Tp&&
>(__e) <
static_cast<_Up&&
>(__f)
1191 ? partial_ordering::less
1192 :
static_cast<_Up&&
>(__f) <
static_cast<_Tp&&
>(__e)
1193 ? partial_ordering::greater
1194 : partial_ordering::unordered;
1201 inline namespace _Cpo
1203 inline constexpr __compare::_Strong_order strong_order{};
1205 inline constexpr __compare::_Weak_order weak_order{};
1207 inline constexpr __compare::_Partial_order partial_order{};
1209 inline constexpr __compare::_Strong_fallback
1210 compare_strong_order_fallback{};
1212 inline constexpr __compare::_Weak_fallback
1213 compare_weak_order_fallback{};
1215 inline constexpr __compare::_Partial_fallback
1216 compare_partial_order_fallback{};
1223 inline constexpr struct _Synth3way
1225 template<
typename _Tp,
typename _Up>
1226 static constexpr bool
1227 _S_noexcept(
const _Tp* __t =
nullptr,
const _Up* __u =
nullptr)
1229 if constexpr (three_way_comparable_with<_Tp, _Up>)
1230 return noexcept(*__t <=> *__u);
1232 return noexcept(*__t < *__u) &&
noexcept(*__u < *__t);
1235 template<
typename _Tp,
typename _Up>
1238 operator()(
const _Tp& __t,
const _Up& __u)
const
1239 noexcept(_S_noexcept<_Tp, _Up>())
1242 { __t < __u } -> __boolean_testable;
1243 { __u < __t } -> __boolean_testable;
1246 if constexpr (three_way_comparable_with<_Tp, _Up>)
1251 return weak_ordering::less;
1253 return weak_ordering::greater;
1255 return weak_ordering::equivalent;
1261 template<
typename _Tp,
typename _Up = _Tp>
1268#if __glibcxx_type_order >= 202506L
1272 template<
typename _Tp,
typename _Up>
1275 static constexpr strong_ordering value = __builtin_type_order(_Tp, _Up);
1276 using value_type = strong_ordering;
1277 constexpr operator value_type() const noexcept {
return value; }
1278 constexpr value_type operator()() const noexcept {
return value; }
1283 template<
typename _Tp,
typename _Up>
1284 inline constexpr strong_ordering type_order_v
1285 = __builtin_type_order(_Tp, _Up);
1291#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
[concept.convertible], concept convertible_to