@@ -722,8 +722,9 @@ public:
722
722
}
723
723
724
724
_NODISCARD_FRIEND auto operator<=>(const _Derived& _Left, const _Derived& _Right) {
725
- return _STD lexicographical_compare_three_way(
726
- _Left.cbegin(), _Left.cend(), _Right.cbegin(), _Right.cend(), _Synth_three_way{});
725
+ return _STD lexicographical_compare_three_way(_STD _Get_unwrapped(_Left.cbegin()),
726
+ _STD _Get_unwrapped(_Left.cend()), _STD _Get_unwrapped(_Right.cbegin()), _STD _Get_unwrapped(_Right.cend()),
727
+ _Synth_three_way{});
727
728
}
728
729
729
730
friend void swap(_Derived& _Left, _Derived& _Right) noexcept {
@@ -737,7 +738,6 @@ protected:
737
738
738
739
template <class _Predicate>
739
740
size_type _Erase_if(_Predicate _Pred) {
740
-
741
741
auto _View = _View_to_mutate();
742
742
auto _Mut_first = _View.begin();
743
743
auto _Mut_last = _View.end();
@@ -848,11 +848,11 @@ private:
848
848
849
849
void _Dedup() {
850
850
_Clear_flat_map_scope_guard _Guard{this};
851
- auto _Sorted_view = _View_to_mutate();
852
- auto _Subrange = _RANGES unique(_Sorted_view, [this](const_reference _Left, const_reference _Right) {
851
+ auto _Sorted_view = _View_to_mutate();
852
+ auto _Subrange = _RANGES unique(_Sorted_view, [this](const_reference _Left, const_reference _Right) {
853
853
return this->_Key_equal(_Left.first, _Right.first);
854
854
});
855
- auto _Remaining_count = _Subrange.begin() - _Sorted_view.begin();
855
+ const auto _Remaining_count = _Subrange.begin() - _Sorted_view.begin();
856
856
_Data.keys.erase(_Data.keys.begin() + _Remaining_count, _Data.keys.end());
857
857
_Data.values.erase(_Data.values.begin() + _Remaining_count, _Data.values.end());
858
858
_Guard._Clearable = nullptr;
@@ -941,36 +941,56 @@ private:
941
941
template <class _KeyTy>
942
942
_NODISCARD iterator _Lower_bound(const _KeyTy& _Key_val) {
943
943
_STL_INTERNAL_STATIC_ASSERT(is_same_v<_KeyTy, key_type> || _Is_transparent_v<key_compare>);
944
- auto _Key_it = _STD lower_bound(_Data.keys.cbegin(), _Data.keys.cend(), _Key_val, _Key_compare);
945
- const auto _Dist = _Key_it - _Data.keys.cbegin();
946
- auto _Val_it = _Data.values.begin() + _Dist;
944
+ const auto _Key_unchecked_begin = _STD _Get_unwrapped(_Data.keys.cbegin());
945
+ const auto _Key_unchecked_it =
946
+ _STD lower_bound(_Key_unchecked_begin, _STD _Get_unwrapped(_Data.keys.cend()), _Key_val, _Key_compare);
947
+ const auto _Dist = _Key_unchecked_it - _Key_unchecked_begin;
948
+
949
+ auto _Key_it = _Data.keys.cbegin();
950
+ _STD _Seek_wrapped(_Key_it, _Key_unchecked_it);
951
+ auto _Val_it = _Data.values.begin() + _Dist;
947
952
return iterator{_STD move(_Key_it), _STD move(_Val_it)};
948
953
}
949
954
950
955
template <class _KeyTy>
951
956
_NODISCARD const_iterator _Lower_bound(const _KeyTy& _Key_val) const {
952
957
_STL_INTERNAL_STATIC_ASSERT(is_same_v<_KeyTy, key_type> || _Is_transparent_v<key_compare>);
953
- auto _Key_it = _STD lower_bound(_Data.keys.cbegin(), _Data.keys.cend(), _Key_val, _Key_compare);
954
- const auto _Dist = _Key_it - _Data.keys.cbegin();
955
- auto _Val_it = _Data.values.cbegin() + _Dist;
958
+ const auto _Key_unchecked_begin = _STD _Get_unwrapped(_Data.keys.cbegin());
959
+ const auto _Key_unchecked_it =
960
+ _STD lower_bound(_Key_unchecked_begin, _STD _Get_unwrapped(_Data.keys.cend()), _Key_val, _Key_compare);
961
+ const auto _Dist = _Key_unchecked_it - _Key_unchecked_begin;
962
+
963
+ auto _Key_it = _Data.keys.cbegin();
964
+ _STD _Seek_wrapped(_Key_it, _Key_unchecked_it);
965
+ auto _Val_it = _Data.values.cbegin() + _Dist;
956
966
return const_iterator{_STD move(_Key_it), _STD move(_Val_it)};
957
967
}
958
968
959
969
template <class _KeyTy>
960
970
_NODISCARD iterator _Upper_bound(const _KeyTy& _Key_val) {
961
971
_STL_INTERNAL_STATIC_ASSERT(is_same_v<_KeyTy, key_type> || _Is_transparent_v<key_compare>);
962
- auto _Key_it = _STD upper_bound(_Data.keys.cbegin(), _Data.keys.cend(), _Key_val, _Key_compare);
963
- const auto _Dist = _Key_it - _Data.keys.cbegin();
964
- auto _Val_it = _Data.values.begin() + _Dist;
972
+ const auto _Key_unchecked_begin = _STD _Get_unwrapped(_Data.keys.cbegin());
973
+ const auto _Key_unchecked_it =
974
+ _STD upper_bound(_Key_unchecked_begin, _STD _Get_unwrapped(_Data.keys.cend()), _Key_val, _Key_compare);
975
+ const auto _Dist = _Key_unchecked_it - _Key_unchecked_begin;
976
+
977
+ auto _Key_it = _Data.keys.cbegin();
978
+ _STD _Seek_wrapped(_Key_it, _Key_unchecked_it);
979
+ auto _Val_it = _Data.values.begin() + _Dist;
965
980
return iterator{_STD move(_Key_it), _STD move(_Val_it)};
966
981
}
967
982
968
983
template <class _KeyTy>
969
984
_NODISCARD const_iterator _Upper_bound(const _KeyTy& _Key_val) const {
970
985
_STL_INTERNAL_STATIC_ASSERT(is_same_v<_KeyTy, key_type> || _Is_transparent_v<key_compare>);
971
- auto _Key_it = _STD upper_bound(_Data.keys.cbegin(), _Data.keys.cend(), _Key_val, _Key_compare);
972
- const auto _Dist = _Key_it - _Data.keys.cbegin();
973
- auto _Val_it = _Data.values.cbegin() + _Dist;
986
+ const auto _Key_unchecked_begin = _STD _Get_unwrapped(_Data.keys.cbegin());
987
+ const auto _Key_unchecked_it =
988
+ _STD upper_bound(_Key_unchecked_begin, _STD _Get_unwrapped(_Data.keys.cend()), _Key_val, _Key_compare);
989
+ const auto _Dist = _Key_unchecked_it - _Key_unchecked_begin;
990
+
991
+ auto _Key_it = _Data.keys.cbegin();
992
+ _STD _Seek_wrapped(_Key_it, _Key_unchecked_it);
993
+ auto _Val_it = _Data.values.cbegin() + _Dist;
974
994
return const_iterator{_STD move(_Key_it), _STD move(_Val_it)};
975
995
}
976
996
0 commit comments