@@ -24,7 +24,12 @@ _LIBCPP_BEGIN_NAMESPACE_STD
24
24
// exposition only
25
25
enum class _OrdResult : signed char { __less = -1 , __equiv = 0 , __greater = 1 };
26
26
27
- enum class _NCmpResult : signed char { __unordered = -127 };
27
+ enum class _PartialOrdResult : signed char {
28
+ __less = static_cast <signed char >(_OrdResult::__less),
29
+ __equiv = static_cast <signed char >(_OrdResult::__equiv),
30
+ __greater = static_cast <signed char >(_OrdResult::__greater),
31
+ __unordered = -127 ,
32
+ };
28
33
29
34
class partial_ordering ;
30
35
class weak_ordering ;
@@ -47,15 +52,7 @@ struct _CmpUnspecifiedParam {
47
52
};
48
53
49
54
class partial_ordering {
50
- using _ValueT = signed char ;
51
-
52
- _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering (_OrdResult __v) noexcept : __value_(_ValueT(__v)) {}
53
-
54
- _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering (_NCmpResult __v) noexcept : __value_(_ValueT(__v)) {}
55
-
56
- _LIBCPP_HIDE_FROM_ABI constexpr bool __is_ordered () const noexcept {
57
- return __value_ != _ValueT (_NCmpResult::__unordered);
58
- }
55
+ _LIBCPP_HIDE_FROM_ABI explicit constexpr partial_ordering (_PartialOrdResult __v) noexcept : __value_(__v) {}
59
56
60
57
public:
61
58
// valid values
@@ -68,39 +65,39 @@ class partial_ordering {
68
65
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(partial_ordering, partial_ordering) noexcept = default ;
69
66
70
67
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator ==(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
71
- return __v.__is_ordered () && __v. __value_ == 0 ;
68
+ return __v.__value_ == _PartialOrdResult::__equiv ;
72
69
}
73
70
74
71
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator <(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
75
- return __v.__is_ordered () && __v. __value_ < 0 ;
72
+ return __v.__value_ == _PartialOrdResult::__less ;
76
73
}
77
74
78
75
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator <=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
79
- return __v.__is_ordered () && __v.__value_ <= 0 ;
76
+ return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less ;
80
77
}
81
78
82
79
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator >(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
83
- return __v.__is_ordered () && __v. __value_ > 0 ;
80
+ return __v.__value_ == _PartialOrdResult::__greater ;
84
81
}
85
82
86
83
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator >=(partial_ordering __v, _CmpUnspecifiedParam) noexcept {
87
- return __v.__is_ordered () && __v.__value_ >= 0 ;
84
+ return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater ;
88
85
}
89
86
90
87
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator <(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
91
- return __v.__is_ordered () && 0 < __v. __value_ ;
88
+ return __v.__value_ == _PartialOrdResult::__greater ;
92
89
}
93
90
94
91
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator <=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
95
- return __v.__is_ordered () && 0 <= __v.__value_ ;
92
+ return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__greater ;
96
93
}
97
94
98
95
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator >(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
99
- return __v.__is_ordered () && 0 > __v. __value_ ;
96
+ return __v.__value_ == _PartialOrdResult::__less ;
100
97
}
101
98
102
99
_LIBCPP_HIDE_FROM_ABI friend constexpr bool operator >=(_CmpUnspecifiedParam, partial_ordering __v) noexcept {
103
- return __v.__is_ordered () && 0 >= __v.__value_ ;
100
+ return __v.__value_ == _PartialOrdResult::__equiv || __v.__value_ == _PartialOrdResult::__less ;
104
101
}
105
102
106
103
_LIBCPP_HIDE_FROM_ABI friend constexpr partial_ordering
@@ -114,13 +111,13 @@ class partial_ordering {
114
111
}
115
112
116
113
private:
117
- _ValueT __value_;
114
+ _PartialOrdResult __value_;
118
115
};
119
116
120
- inline constexpr partial_ordering partial_ordering::less (_OrdResult ::__less);
121
- inline constexpr partial_ordering partial_ordering::equivalent (_OrdResult ::__equiv);
122
- inline constexpr partial_ordering partial_ordering::greater (_OrdResult ::__greater);
123
- inline constexpr partial_ordering partial_ordering::unordered (_NCmpResult ::__unordered);
117
+ inline constexpr partial_ordering partial_ordering::less (_PartialOrdResult ::__less);
118
+ inline constexpr partial_ordering partial_ordering::equivalent (_PartialOrdResult ::__equiv);
119
+ inline constexpr partial_ordering partial_ordering::greater (_PartialOrdResult ::__greater);
120
+ inline constexpr partial_ordering partial_ordering::unordered (_PartialOrdResult ::__unordered);
124
121
125
122
class weak_ordering {
126
123
using _ValueT = signed char ;
0 commit comments