enum class _Ord : type { equivalent = 0, less = -1, greater = 1 };
- enum class _Ncmp : type { _Unordered = 2 };
+ enum class _Ncmp : type { unordered = -__SCHAR_MAX__ - 1 };
struct __unspec
{
class partial_ordering
{
- // less=0xff, equiv=0x00, greater=0x01, unordered=0x02
+ // less=0xff, equiv=0x00, greater=0x01, unordered=0x80
__cmp_cat::type _M_value;
constexpr explicit
friend class weak_ordering;
friend class strong_ordering;
+ [[__gnu__::__always_inline__]]
+ constexpr __cmp_cat::type
+ _M_reverse() const
+ {
+ // leaves _Ncmp::unordered unchanged
+ return static_cast<__cmp_cat::type>(-_M_value);
+ }
+
public:
// valid values
static const partial_ordering less;
[[nodiscard]]
friend constexpr bool
operator<=(partial_ordering __v, __cmp_cat::__unspec) noexcept
- { return __v._M_value <= 0; }
+ { return __v._M_reverse() >= 0; }
[[nodiscard]]
friend constexpr bool
operator>=(partial_ordering __v, __cmp_cat::__unspec) noexcept
- { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; }
+ { return __v._M_value >= 0; }
[[nodiscard]]
friend constexpr bool
[[nodiscard]]
friend constexpr bool
operator<=(__cmp_cat::__unspec, partial_ordering __v) noexcept
- { return __cmp_cat::type(__v._M_value & 1) == __v._M_value; }
+ { return 0 <= __v._M_value; }
[[nodiscard]]
friend constexpr bool
operator>=(__cmp_cat::__unspec, partial_ordering __v) noexcept
- { return 0 >= __v._M_value; }
+ { return 0 <= __v._M_reverse(); }
[[nodiscard]]
friend constexpr partial_ordering
partial_ordering::greater(__cmp_cat::_Ord::greater);
inline constexpr partial_ordering
- partial_ordering::unordered(__cmp_cat::_Ncmp::_Unordered);
+ partial_ordering::unordered(__cmp_cat::_Ncmp::unordered);
class weak_ordering
{
if self._typename == 'strong_ordering' and self._val == 0:
name = 'equal'
else:
- names = {2: 'unordered', -1: 'less', 0: 'equivalent', 1: 'greater'}
+ names = {
+ -1: 'less', 0: 'equivalent', 1: 'greater',
+ # GCC 10-15 used 2 for unordered
+ -128: 'unordered', 2: 'unordered'
+ }
name = names[int(self._val)]
return 'std::{}::{}'.format(self._typename, name)