diff --git a/libcxx/include/compare b/libcxx/include/compare --- a/libcxx/include/compare +++ b/libcxx/include/compare @@ -182,21 +182,51 @@ static const partial_ordering unordered; // comparisons - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering, partial_ordering) noexcept = default; - _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept; + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ == 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ < 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ <= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ > 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__is_ordered() && __v.__value_ >= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 < __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 <= __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 > __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v.__is_ordered() && 0 >= __v.__value_; + } + _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { + return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); + } private: _ValueT __value_; }; @@ -206,53 +236,6 @@ _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::greater(_OrdResult::__greater); _LIBCPP_INLINE_VAR constexpr partial_ordering partial_ordering::unordered(_NCmpResult ::__unordered); -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator==(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ == 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ < 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ <= 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ > 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__is_ordered() && __v.__value_ >= 0; -} - -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 < __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 <= __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 > __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v.__is_ordered() && 0 >= __v.__value_; -} - -_LIBCPP_INLINE_VISIBILITY -constexpr partial_ordering operator<=>(partial_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; -} -_LIBCPP_INLINE_VISIBILITY -constexpr partial_ordering operator<=>(_CmpUnspecifiedParam, partial_ordering __v) noexcept { - return __v < 0 ? partial_ordering::greater : (__v > 0 ? partial_ordering::less : __v); -} - class weak_ordering { using _ValueT = signed char; @@ -273,20 +256,51 @@ } // comparisons - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering, weak_ordering) noexcept = default; - _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept; + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ < 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ <= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ > 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ >= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 < __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 <= __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 > __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return 0 >= __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { + return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); + } private: _ValueT __value_; @@ -295,52 +309,6 @@ _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::less(_OrdResult::__less); _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::equivalent(_EqResult::__equiv); _LIBCPP_INLINE_VAR constexpr weak_ordering weak_ordering::greater(_OrdResult::__greater); - -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator==(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ == 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ < 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ <= 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ > 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ >= 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 < __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 <= __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 > __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return 0 >= __v.__value_; -} - -_LIBCPP_INLINE_VISIBILITY -constexpr weak_ordering operator<=>(weak_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; -} -_LIBCPP_INLINE_VISIBILITY -constexpr weak_ordering operator<=>(_CmpUnspecifiedParam, weak_ordering __v) noexcept { - return __v < 0 ? weak_ordering::greater : (__v > 0 ? weak_ordering::less : __v); -} class strong_ordering { using _ValueT = signed char; @@ -369,20 +337,51 @@ } // comparisons - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering, strong_ordering) noexcept = default; - _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept; - _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept; + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ == 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ < 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ <= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ > 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v.__value_ >= 0; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 < __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 <= __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 > __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return 0 >= __v.__value_; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { + return __v; + } + + _LIBCPP_INLINE_VISIBILITY friend constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { + return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); + } private: _ValueT __value_; @@ -393,52 +392,6 @@ _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::equivalent(_EqResult::__equiv); _LIBCPP_INLINE_VAR constexpr strong_ordering strong_ordering::greater(_OrdResult::__greater); -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator==(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ == 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ < 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ <= 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ > 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v.__value_ >= 0; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator< (_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 < __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator<=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 <= __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator> (_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 > __v.__value_; -} -_LIBCPP_INLINE_VISIBILITY -constexpr bool operator>=(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return 0 >= __v.__value_; -} - -_LIBCPP_INLINE_VISIBILITY -constexpr strong_ordering operator<=>(strong_ordering __v, _CmpUnspecifiedParam) noexcept { - return __v; -} -_LIBCPP_INLINE_VISIBILITY -constexpr strong_ordering operator<=>(_CmpUnspecifiedParam, strong_ordering __v) noexcept { - return __v < 0 ? strong_ordering::greater : (__v > 0 ? strong_ordering::less : __v); -} - // named comparison functions _LIBCPP_INLINE_VISIBILITY constexpr bool is_lt(partial_ordering __cmp) noexcept { return __cmp < 0; }