@@ -1030,8 +1030,7 @@ public:
1030
1030
template <class _Key >
1031
1031
_LIBCPP_HIDE_FROM_ABI size_type __erase_multi (const _Key& __k);
1032
1032
1033
- _LIBCPP_HIDE_FROM_ABI void
1034
- __insert_node_at (__end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT;
1033
+ _LIBCPP_HIDE_FROM_ABI void __insert_node_at (__end_node_pointer __parent, __node_base_pointer __new_node) _NOEXCEPT;
1035
1034
1036
1035
template <class _Key >
1037
1036
_LIBCPP_HIDE_FROM_ABI iterator find (const _Key& __v);
@@ -1737,15 +1736,18 @@ typename __tree<_Tp, _Compare, _Allocator>::__node_base_pointer& __tree<_Tp, _Co
1737
1736
1738
1737
template <class _Tp , class _Compare , class _Allocator >
1739
1738
void __tree<_Tp, _Compare, _Allocator>::__insert_node_at(
1740
- __end_node_pointer __parent, __node_base_pointer& __child, __node_base_pointer __new_node) _NOEXCEPT {
1739
+ __end_node_pointer __parent, __node_base_pointer __new_node) _NOEXCEPT {
1740
+ _LIBCPP_ASSERT_INTERNAL (
1741
+ __parent->__left_ == __new_node ||
1742
+ (__parent != __end_node () && static_cast <__node_base_pointer>(__parent)->__right == __new_node),
1743
+ " __parent isn't the parent of __new_node!" );
1741
1744
__new_node->__left_ = nullptr ;
1742
1745
__new_node->__right_ = nullptr ;
1743
1746
__new_node->__parent_ = __parent;
1744
1747
// __new_node->__is_black_ is initialized in __tree_balance_after_insert
1745
- __child = __new_node;
1746
1748
if (__begin_node_->__left_ != nullptr )
1747
1749
__begin_node_ = static_cast <__end_node_pointer>(__begin_node_->__left_ );
1748
- std::__tree_balance_after_insert (__end_node ()->__left_ , __child );
1750
+ std::__tree_balance_after_insert (__end_node ()->__left_ , __new_node );
1749
1751
++__size_;
1750
1752
}
1751
1753
@@ -1759,7 +1761,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_key_args(_Key const& __k, _A
1759
1761
bool __inserted = false ;
1760
1762
if (__child == nullptr ) {
1761
1763
__node_holder __h = __construct_node (std::forward<_Args>(__args)...);
1762
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1764
+ __child = static_cast <__node_base_pointer>(__h.get ());
1765
+ __insert_node_at (__parent, __child);
1763
1766
__r = __h.release ();
1764
1767
__inserted = true ;
1765
1768
}
@@ -1778,7 +1781,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_key_args(
1778
1781
bool __inserted = false ;
1779
1782
if (__child == nullptr ) {
1780
1783
__node_holder __h = __construct_node (std::forward<_Args>(__args)...);
1781
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1784
+ __child = static_cast <__node_base_pointer>(__h.get ());
1785
+ __insert_node_at (__parent, __child);
1782
1786
__r = __h.release ();
1783
1787
__inserted = true ;
1784
1788
}
@@ -1806,7 +1810,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_unique_impl(_Args&&... __args) {
1806
1810
__node_pointer __r = static_cast <__node_pointer>(__child);
1807
1811
bool __inserted = false ;
1808
1812
if (__child == nullptr ) {
1809
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1813
+ __child = static_cast <__node_base_pointer>(__h.get ());
1814
+ __insert_node_at (__parent, __child);
1810
1815
__r = __h.release ();
1811
1816
__inserted = true ;
1812
1817
}
@@ -1823,7 +1828,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_unique_impl(const_iterator __p
1823
1828
__node_base_pointer& __child = __find_equal (__p, __parent, __dummy, __h->__value_ );
1824
1829
__node_pointer __r = static_cast <__node_pointer>(__child);
1825
1830
if (__child == nullptr ) {
1826
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1831
+ __child = static_cast <__node_base_pointer>(__h.get ());
1832
+ __insert_node_at (__parent, __child);
1827
1833
__r = __h.release ();
1828
1834
}
1829
1835
return iterator (__r);
@@ -1836,7 +1842,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_multi(_Args&&... __args) {
1836
1842
__node_holder __h = __construct_node (std::forward<_Args>(__args)...);
1837
1843
__end_node_pointer __parent;
1838
1844
__node_base_pointer& __child = __find_leaf_high (__parent, __h->__value_ );
1839
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1845
+ __child = static_cast <__node_base_pointer>(__h.get ());
1846
+ __insert_node_at (__parent, __child);
1840
1847
return iterator (static_cast <__node_pointer>(__h.release ()));
1841
1848
}
1842
1849
@@ -1847,7 +1854,8 @@ __tree<_Tp, _Compare, _Allocator>::__emplace_hint_multi(const_iterator __p, _Arg
1847
1854
__node_holder __h = __construct_node (std::forward<_Args>(__args)...);
1848
1855
__end_node_pointer __parent;
1849
1856
__node_base_pointer& __child = __find_leaf (__p, __parent, __h->__value_ );
1850
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__h.get ()));
1857
+ __child = static_cast <__node_base_pointer>(__h.get ());
1858
+ __insert_node_at (__parent, __child);
1851
1859
return iterator (static_cast <__node_pointer>(__h.release ()));
1852
1860
}
1853
1861
@@ -1860,7 +1868,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_assign_unique(const value_type& __v, _
1860
1868
bool __inserted = false ;
1861
1869
if (__child == nullptr ) {
1862
1870
__assign_value (__nd->__value_ , __v);
1863
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__nd));
1871
+ __child = static_cast <__node_base_pointer>(__nd);
1872
+ __insert_node_at (__parent, __child);
1864
1873
__r = __nd;
1865
1874
__inserted = true ;
1866
1875
}
@@ -1872,7 +1881,8 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator
1872
1881
__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(__node_pointer __nd) {
1873
1882
__end_node_pointer __parent;
1874
1883
__node_base_pointer& __child = __find_leaf_high (__parent, __nd->__value_ );
1875
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__nd));
1884
+ __child = static_cast <__node_base_pointer>(__nd);
1885
+ __insert_node_at (__parent, __child);
1876
1886
return iterator (__nd);
1877
1887
}
1878
1888
@@ -1881,7 +1891,8 @@ typename __tree<_Tp, _Compare, _Allocator>::iterator
1881
1891
__tree<_Tp, _Compare, _Allocator>::__node_insert_multi(const_iterator __p, __node_pointer __nd) {
1882
1892
__end_node_pointer __parent;
1883
1893
__node_base_pointer& __child = __find_leaf (__p, __parent, __nd->__value_ );
1884
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__nd));
1894
+ __child = static_cast <__node_base_pointer>(__nd);
1895
+ __insert_node_at (__parent, __child);
1885
1896
return iterator (__nd);
1886
1897
}
1887
1898
@@ -1911,7 +1922,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(_NodeHandle&& __n
1911
1922
if (__child != nullptr )
1912
1923
return _InsertReturnType{iterator (static_cast <__node_pointer>(__child)), false , std::move (__nh)};
1913
1924
1914
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__ptr));
1925
+ __child = static_cast <__node_base_pointer>(__ptr);
1926
+ __insert_node_at (__parent, __child);
1915
1927
__nh.__release_ptr ();
1916
1928
return _InsertReturnType{iterator (__ptr), true , _NodeHandle ()};
1917
1929
}
@@ -1929,7 +1941,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_unique(const_iterator __
1929
1941
__node_base_pointer& __child = __find_equal (__hint, __parent, __dummy, __ptr->__value_ );
1930
1942
__node_pointer __r = static_cast <__node_pointer>(__child);
1931
1943
if (__child == nullptr ) {
1932
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__ptr));
1944
+ __child = static_cast <__node_base_pointer>(__ptr);
1945
+ __insert_node_at (__parent, __child);
1933
1946
__r = __ptr;
1934
1947
__nh.__release_ptr ();
1935
1948
}
@@ -1966,7 +1979,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg
1966
1979
if (__child != nullptr )
1967
1980
continue ;
1968
1981
__source.__remove_node_pointer (__src_ptr);
1969
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__src_ptr));
1982
+ __child = static_cast <__node_base_pointer>(__src_ptr);
1983
+ __insert_node_at (__parent, __child);
1970
1984
}
1971
1985
}
1972
1986
@@ -1979,7 +1993,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(_NodeHandle&& __nh
1979
1993
__node_pointer __ptr = __nh.__ptr_ ;
1980
1994
__end_node_pointer __parent;
1981
1995
__node_base_pointer& __child = __find_leaf_high (__parent, __ptr->__value_ );
1982
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__ptr));
1996
+ __child = static_cast <__node_base_pointer>(__ptr);
1997
+ __insert_node_at (__parent, __child);
1983
1998
__nh.__release_ptr ();
1984
1999
return iterator (__ptr);
1985
2000
}
@@ -1994,7 +2009,8 @@ __tree<_Tp, _Compare, _Allocator>::__node_handle_insert_multi(const_iterator __h
1994
2009
__node_pointer __ptr = __nh.__ptr_ ;
1995
2010
__end_node_pointer __parent;
1996
2011
__node_base_pointer& __child = __find_leaf (__hint, __parent, __ptr->__value_ );
1997
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__ptr));
2012
+ __child = static_cast <__node_base_pointer>(__ptr);
2013
+ __insert_node_at (__parent, __child);
1998
2014
__nh.__release_ptr ();
1999
2015
return iterator (__ptr);
2000
2016
}
@@ -2010,7 +2026,8 @@ _LIBCPP_HIDE_FROM_ABI void __tree<_Tp, _Compare, _Allocator>::__node_handle_merg
2010
2026
__node_base_pointer& __child = __find_leaf_high (__parent, __src_ptr->__value_ );
2011
2027
++__i;
2012
2028
__source.__remove_node_pointer (__src_ptr);
2013
- __insert_node_at (__parent, __child, static_cast <__node_base_pointer>(__src_ptr));
2029
+ __child = static_cast <__node_base_pointer>(__src_ptr);
2030
+ __insert_node_at (__parent, __child);
2014
2031
}
2015
2032
}
2016
2033
0 commit comments