@@ -38,7 +38,6 @@ template <typename T> class byterator {
38
38
byterator const &y) -> bool {
39
39
return x.ptr == y.ptr ;
40
40
}
41
-
42
41
template <typename It,
43
42
std::enable_if_t <std::is_same_v<detail::iterator_value_t <It>, T>,
44
43
int > = 0 >
@@ -49,47 +48,103 @@ template <typename T> class byterator {
49
48
}
50
49
51
50
#if __cpp_impl_three_way_comparison >= 201907L
52
- [[nodiscard]] constexpr friend auto operator <=>(byterator const &x,
51
+ [[nodiscard]] friend constexpr auto operator <=>(byterator const &x,
53
52
byterator const &y) {
54
53
return x.ptr <=> y.ptr ;
55
54
}
56
- #else
57
- [[nodiscard]] constexpr friend auto operator !=(byterator const &x,
58
- byterator const &y) -> bool {
59
- return not (x == y);
55
+ template <typename It,
56
+ std::enable_if_t <std::is_same_v<detail::iterator_value_t <It>, T>,
57
+ int > = 0 >
58
+ [[nodiscard]] friend constexpr auto operator <=>(byterator const &x, It y) {
59
+ return static_cast <void const *>(x.ptr ) <=>
60
+ static_cast <void const *>(stdx::to_address (y));
60
61
}
61
-
62
+ # else
62
63
template <typename It>
63
- [[nodiscard]] friend constexpr auto operator ==(It y , byterator const &x )
64
+ [[nodiscard]] friend constexpr auto operator ==(It x , byterator const &y )
64
65
-> bool {
65
- return x == y;
66
+ return y == x;
67
+ }
68
+
69
+ [[nodiscard]] friend constexpr auto operator !=(byterator const &x,
70
+ byterator const &y) -> bool {
71
+ return not (x == y);
66
72
}
67
73
template <typename It>
68
74
[[nodiscard]] friend constexpr auto operator !=(byterator const &x, It y)
69
75
-> bool {
70
76
return not (x == y);
71
77
}
72
78
template <typename It>
73
- [[nodiscard]] friend constexpr auto operator !=(It y , byterator const &x )
79
+ [[nodiscard]] friend constexpr auto operator !=(It x , byterator const &y )
74
80
-> bool {
75
- return not (x == y) ;
81
+ return y != x ;
76
82
}
77
83
78
84
[[nodiscard]] friend constexpr auto operator <(byterator const &x,
79
85
byterator const &y) -> bool {
80
86
return std::less{}(x.ptr , y.ptr );
81
87
}
88
+ template <typename It,
89
+ std::enable_if_t <std::is_same_v<detail::iterator_value_t <It>, T>,
90
+ int > = 0 >
91
+ [[nodiscard]] friend constexpr auto operator <(byterator const &x, It y)
92
+ -> bool {
93
+ return std::less{}(static_cast <void const *>(x.ptr ),
94
+ static_cast <void const *>(stdx::to_address (y)));
95
+ }
96
+ template <typename It,
97
+ std::enable_if_t <std::is_same_v<detail::iterator_value_t <It>, T>,
98
+ int > = 0 >
99
+ [[nodiscard]] friend constexpr auto operator <(It x, byterator const &y)
100
+ -> bool {
101
+ return std::less{}(static_cast <void const *>(stdx::to_address (x)),
102
+ static_cast <void const *>(y.ptr ));
103
+ }
104
+
82
105
[[nodiscard]] friend constexpr auto operator <=(byterator const &x,
83
106
byterator const &y) -> bool {
84
- return std::less_equal{}(x.ptr , y.ptr );
107
+ return not (y < x);
108
+ }
109
+ template <typename It>
110
+ [[nodiscard]] friend constexpr auto operator <=(byterator const &x, It y)
111
+ -> bool {
112
+ return not (y < x);
85
113
}
114
+ template <typename It>
115
+ [[nodiscard]] friend constexpr auto operator <=(It x, byterator const &y)
116
+ -> bool {
117
+ return not (y < x);
118
+ }
119
+
86
120
[[nodiscard]] friend constexpr auto operator >(byterator const &x,
87
121
byterator const &y) -> bool {
88
- return std::greater{}(x. ptr , y. ptr ) ;
122
+ return y < x ;
89
123
}
124
+ template <typename It>
125
+ [[nodiscard]] friend constexpr auto operator >(byterator const &x, It y)
126
+ -> bool {
127
+ return y < x;
128
+ }
129
+ template <typename It>
130
+ [[nodiscard]] friend constexpr auto operator >(It x, byterator const &y)
131
+ -> bool {
132
+ return y < x;
133
+ }
134
+
90
135
[[nodiscard]] friend constexpr auto operator >=(byterator const &x,
91
136
byterator const &y) -> bool {
92
- return std::greater_equal{}(x.ptr , y.ptr );
137
+ return not (x < y);
138
+ }
139
+ template <typename It>
140
+ [[nodiscard]] friend constexpr auto operator >=(byterator const &x, It y)
141
+ -> bool {
142
+ return not (x < y);
143
+ }
144
+ template <typename It>
145
+ [[nodiscard]] friend constexpr auto operator >=(It x, byterator const &y)
146
+ -> bool {
147
+ return not (x < y);
93
148
}
94
149
#endif
95
150
0 commit comments