@@ -766,6 +766,14 @@ public:
766
766
typedef __rebind_alloc<__alloc_traits, __node> __node_allocator;
767
767
typedef allocator_traits<__node_allocator> __node_traits;
768
768
769
+ enum class __uniqueness {
770
+ __unique,
771
+ __multi,
772
+ };
773
+
774
+ using __unique_tag = integral_constant<__uniqueness, __uniqueness::__unique>;
775
+ using __multi_tag = integral_constant<__uniqueness, __uniqueness::__multi>;
776
+
769
777
// TODO(LLVM 22): Remove this check
770
778
#ifndef _LIBCPP_ABI_TREE_REMOVE_NODE_POINTER_UB
771
779
static_assert (sizeof (__node_base_pointer) == sizeof(__end_node_pointer) && _LIBCPP_ALIGNOF(__node_base_pointer) ==
@@ -1009,9 +1017,27 @@ public:
1009
1017
__insert_node_at (__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;
1010
1018
1011
1019
template <class _Key >
1012
- _LIBCPP_HIDE_FROM_ABI iterator find (const _Key& __v);
1020
+ _LIBCPP_HIDE_FROM_ABI iterator find (__multi_tag, const _Key& __v);
1021
+ template <class _Key >
1022
+ _LIBCPP_HIDE_FROM_ABI const_iterator find (__multi_tag, const _Key& __v) const ;
1023
+
1024
+ template <class _Key >
1025
+ _LIBCPP_HIDE_FROM_ABI iterator find (__unique_tag, const _Key& __key) {
1026
+ __end_node_pointer __parent;
1027
+ __node_base_pointer __match = __find_equal (__parent, __key);
1028
+ if (__match == nullptr )
1029
+ return end ();
1030
+ return iterator (static_cast <__node_pointer>(__match));
1031
+ }
1032
+
1013
1033
template <class _Key >
1014
- _LIBCPP_HIDE_FROM_ABI const_iterator find (const _Key& __v) const ;
1034
+ _LIBCPP_HIDE_FROM_ABI const_iterator find (__unique_tag, const _Key& __key) const {
1035
+ __end_node_pointer __parent;
1036
+ __node_base_pointer __match = __find_equal (__parent, __key);
1037
+ if (__match == nullptr )
1038
+ return end ();
1039
+ return const_iterator (static_cast <__node_pointer>(__match));
1040
+ }
1015
1041
1016
1042
template <class _Key >
1017
1043
_LIBCPP_HIDE_FROM_ABI size_type __count_unique (const _Key& __k) const ;
@@ -1914,7 +1940,7 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
1914
1940
template <class _Tp , class _Compare , class _Allocator >
1915
1941
template <class _NodeHandle >
1916
1942
_LIBCPP_HIDE_FROM_ABI _NodeHandle __tree<_Tp, _Compare, _Allocator>::__node_handle_extract(key_type const & __key) {
1917
- iterator __it = find (__key);
1943
+ iterator __it = find (__multi_tag (), __key);
1918
1944
if (__it == end ())
1919
1945
return _NodeHandle ();
1920
1946
return __node_handle_extract<_NodeHandle>(__it);
@@ -2013,7 +2039,7 @@ template <class _Tp, class _Compare, class _Allocator>
2013
2039
template <class _Key >
2014
2040
typename __tree<_Tp, _Compare, _Allocator>::size_type
2015
2041
__tree<_Tp, _Compare, _Allocator>::__erase_unique(const _Key& __k) {
2016
- iterator __i = find (__k);
2042
+ iterator __i = find (__unique_tag (), __k);
2017
2043
if (__i == end ())
2018
2044
return 0 ;
2019
2045
erase (__i);
@@ -2033,7 +2059,8 @@ __tree<_Tp, _Compare, _Allocator>::__erase_multi(const _Key& __k) {
2033
2059
2034
2060
template <class _Tp , class _Compare , class _Allocator >
2035
2061
template <class _Key >
2036
- typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) {
2062
+ typename __tree<_Tp, _Compare, _Allocator>::iterator
2063
+ __tree<_Tp, _Compare, _Allocator>::find(__multi_tag, const _Key& __v) {
2037
2064
iterator __p = __lower_bound (__v, __root (), __end_node ());
2038
2065
if (__p != end () && !value_comp ()(__v, *__p))
2039
2066
return __p;
@@ -2043,7 +2070,7 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator __tree<_Tp, _Compare, _Allo
2043
2070
template <class _Tp , class _Compare , class _Allocator >
2044
2071
template <class _Key >
2045
2072
typename __tree<_Tp, _Compare, _Allocator>::const_iterator
2046
- __tree<_Tp, _Compare, _Allocator>::find(const _Key& __v) const {
2073
+ __tree<_Tp, _Compare, _Allocator>::find(__multi_tag, const _Key& __v) const {
2047
2074
const_iterator __p = __lower_bound (__v, __root (), __end_node ());
2048
2075
if (__p != end () && !value_comp ()(__v, *__p))
2049
2076
return __p;
0 commit comments