34
34
#include < __type_traits/is_swappable.h>
35
35
#include < __type_traits/remove_const.h>
36
36
#include < __utility/forward.h>
37
+ #include < __utility/lazy_synth_three_way_comparator.h>
37
38
#include < __utility/move.h>
38
39
#include < __utility/pair.h>
39
40
#include < __utility/swap.h>
@@ -1749,14 +1750,18 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(const _Key& __v) {
1749
1750
}
1750
1751
1751
1752
__node_base_pointer* __node_ptr = __root_ptr ();
1753
+ auto __comp = __lazy_synth_three_way_comparator<_Compare, _Key, value_type>(value_comp ());
1754
+
1752
1755
while (true ) {
1753
- if (value_comp ()(__v, __nd->__get_value ())) {
1756
+ auto __comp_res = __comp (__v, __nd->__get_value ());
1757
+
1758
+ if (__comp_res.__less ()) {
1754
1759
if (__nd->__left_ == nullptr )
1755
1760
return _Pair (static_cast <__end_node_pointer>(__nd), __nd->__left_ );
1756
1761
1757
1762
__node_ptr = std::addressof (__nd->__left_ );
1758
1763
__nd = static_cast <__node_pointer>(__nd->__left_ );
1759
- } else if (value_comp ()(__nd-> __get_value (), __v )) {
1764
+ } else if (__comp_res. __greater ( )) {
1760
1765
if (__nd->__right_ == nullptr )
1761
1766
return _Pair (static_cast <__end_node_pointer>(__nd), __nd->__right_ );
1762
1767
@@ -2065,10 +2070,12 @@ template <class _Key>
2065
2070
typename __tree<_Tp, _Compare, _Allocator>::size_type
2066
2071
__tree<_Tp, _Compare, _Allocator>::__count_unique(const _Key& __k) const {
2067
2072
__node_pointer __rt = __root ();
2073
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2068
2074
while (__rt != nullptr ) {
2069
- if (value_comp ()(__k, __rt->__get_value ())) {
2075
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2076
+ if (__comp_res.__less ()) {
2070
2077
__rt = static_cast <__node_pointer>(__rt->__left_ );
2071
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2078
+ } else if (__comp_res. __greater ( ))
2072
2079
__rt = static_cast <__node_pointer>(__rt->__right_ );
2073
2080
else
2074
2081
return 1 ;
@@ -2082,11 +2089,13 @@ typename __tree<_Tp, _Compare, _Allocator>::size_type
2082
2089
__tree<_Tp, _Compare, _Allocator>::__count_multi(const _Key& __k) const {
2083
2090
__end_node_pointer __result = __end_node ();
2084
2091
__node_pointer __rt = __root ();
2092
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2085
2093
while (__rt != nullptr ) {
2086
- if (value_comp ()(__k, __rt->__get_value ())) {
2094
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2095
+ if (__comp_res.__less ()) {
2087
2096
__result = static_cast <__end_node_pointer>(__rt);
2088
2097
__rt = static_cast <__node_pointer>(__rt->__left_ );
2089
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2098
+ } else if (__comp_res. __greater ( ))
2090
2099
__rt = static_cast <__node_pointer>(__rt->__right_ );
2091
2100
else
2092
2101
return std::distance (
@@ -2159,11 +2168,13 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) {
2159
2168
using _Pp = pair<iterator, iterator>;
2160
2169
__end_node_pointer __result = __end_node ();
2161
2170
__node_pointer __rt = __root ();
2171
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2162
2172
while (__rt != nullptr ) {
2163
- if (value_comp ()(__k, __rt->__get_value ())) {
2173
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2174
+ if (__comp_res.__less ()) {
2164
2175
__result = static_cast <__end_node_pointer>(__rt);
2165
2176
__rt = static_cast <__node_pointer>(__rt->__left_ );
2166
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2177
+ } else if (__comp_res. __greater ( ))
2167
2178
__rt = static_cast <__node_pointer>(__rt->__right_ );
2168
2179
else
2169
2180
return _Pp (iterator (__rt),
@@ -2181,11 +2192,13 @@ __tree<_Tp, _Compare, _Allocator>::__equal_range_unique(const _Key& __k) const {
2181
2192
using _Pp = pair<const_iterator, const_iterator>;
2182
2193
__end_node_pointer __result = __end_node ();
2183
2194
__node_pointer __rt = __root ();
2195
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2184
2196
while (__rt != nullptr ) {
2185
- if (value_comp ()(__k, __rt->__get_value ())) {
2197
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2198
+ if (__comp_res.__less ()) {
2186
2199
__result = static_cast <__end_node_pointer>(__rt);
2187
2200
__rt = static_cast <__node_pointer>(__rt->__left_ );
2188
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2201
+ } else if (__comp_res. __greater ( ))
2189
2202
__rt = static_cast <__node_pointer>(__rt->__right_ );
2190
2203
else
2191
2204
return _Pp (
@@ -2202,12 +2215,14 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::iterator, typename __tree<_Tp,
2202
2215
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) {
2203
2216
using _Pp = pair<iterator, iterator>;
2204
2217
__end_node_pointer __result = __end_node ();
2205
- __node_pointer __rt = __root ();
2218
+ __node_pointer __rt = __root ();
2219
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2206
2220
while (__rt != nullptr ) {
2207
- if (value_comp ()(__k, __rt->__get_value ())) {
2221
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2222
+ if (__comp_res.__less ()) {
2208
2223
__result = static_cast <__end_node_pointer>(__rt);
2209
2224
__rt = static_cast <__node_pointer>(__rt->__left_ );
2210
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2225
+ } else if (__comp_res. __greater ( ))
2211
2226
__rt = static_cast <__node_pointer>(__rt->__right_ );
2212
2227
else
2213
2228
return _Pp (__lower_bound (__k, static_cast <__node_pointer>(__rt->__left_ ), static_cast <__end_node_pointer>(__rt)),
@@ -2223,12 +2238,14 @@ pair<typename __tree<_Tp, _Compare, _Allocator>::const_iterator,
2223
2238
__tree<_Tp, _Compare, _Allocator>::__equal_range_multi(const _Key& __k) const {
2224
2239
using _Pp = pair<const_iterator, const_iterator>;
2225
2240
__end_node_pointer __result = __end_node ();
2226
- __node_pointer __rt = __root ();
2241
+ __node_pointer __rt = __root ();
2242
+ auto __comp = __lazy_synth_three_way_comparator<value_compare, _Key, value_type>(value_comp ());
2227
2243
while (__rt != nullptr ) {
2228
- if (value_comp ()(__k, __rt->__get_value ())) {
2244
+ auto __comp_res = __comp (__k, __rt->__get_value ());
2245
+ if (__comp_res.__less ()) {
2229
2246
__result = static_cast <__end_node_pointer>(__rt);
2230
2247
__rt = static_cast <__node_pointer>(__rt->__left_ );
2231
- } else if (value_comp ()(__rt-> __get_value (), __k ))
2248
+ } else if (__comp_res. __greater ( ))
2232
2249
__rt = static_cast <__node_pointer>(__rt->__right_ );
2233
2250
else
2234
2251
return _Pp (__lower_bound (__k, static_cast <__node_pointer>(__rt->__left_ ), static_cast <__end_node_pointer>(__rt)),
0 commit comments