10
10
#ifndef _LIBCPP___TREE
11
11
#define _LIBCPP___TREE
12
12
13
+ #include " __memory/pointer_traits.h"
13
14
#include < __algorithm/min.h>
14
15
#include < __assert>
15
16
#include < __config>
@@ -569,11 +570,11 @@ public:
569
570
bool __is_black_;
570
571
571
572
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 pointer __parent_unsafe () const {
572
- return static_cast <pointer>(__parent_);
573
+ return std::__static_fancy_pointer_cast <pointer>(__parent_);
573
574
}
574
575
575
576
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 void __set_parent (pointer __p) {
576
- __parent_ = static_cast <__end_node_pointer>(__p);
577
+ __parent_ = std::__static_fancy_pointer_cast <__end_node_pointer>(__p);
577
578
}
578
579
579
580
// template <typename... Args> constexpr __tree_node_base(Args && ... args) =default;
@@ -702,7 +703,7 @@ public:
702
703
703
704
private:
704
705
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator (__node_pointer __p) _NOEXCEPT
705
- : __ptr_(__p) {}
706
+ : __ptr_(std::__static_fancy_pointer_cast<__end_node_pointer>( __p) ) {}
706
707
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator (__end_node_pointer __p) _NOEXCEPT
707
708
: __ptr_(__p) {}
708
709
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np () const {
@@ -772,7 +773,7 @@ public:
772
773
}
773
774
774
775
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree_const_iterator& operator --() {
775
- __ptr_ = static_cast <__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
776
+ __ptr_ = std::__static_fancy_pointer_cast <__end_node_pointer>(std::__tree_prev_iter<__node_base_pointer>(__ptr_));
776
777
return *this ;
777
778
}
778
779
@@ -797,7 +798,7 @@ private:
797
798
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator (__end_node_pointer __p) _NOEXCEPT
798
799
: __ptr_(__p) {}
799
800
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np () const {
800
- return static_cast <__node_pointer>(__ptr_);
801
+ return std::__static_fancy_pointer_cast <__node_pointer>(__ptr_);
801
802
}
802
803
803
804
template <class , class , class >
@@ -923,7 +924,7 @@ public:
923
924
924
925
public:
925
926
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __root () const _NOEXCEPT {
926
- return static_cast <__node_pointer>(__end_node ()->__left_ );
927
+ return std::__static_fancy_pointer_cast <__node_pointer>(__end_node ()->__left_ );
927
928
}
928
929
929
930
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_base_pointer* __root_ptr () const _NOEXCEPT {
@@ -1558,8 +1559,8 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 __tree<_Tp, _Compare, _Allocator>::~__tree() {
1558
1559
template <class _Tp , class _Compare , class _Allocator >
1559
1560
_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
1560
1561
if (__nd != nullptr ) {
1561
- destroy (static_cast <__node_pointer>(__nd->__left_ ));
1562
- destroy (static_cast <__node_pointer>(__nd->__right_ ));
1562
+ destroy (std::__static_fancy_pointer_cast <__node_pointer>(__nd->__left_ ));
1563
+ destroy (std::__static_fancy_pointer_cast <__node_pointer>(__nd->__right_ ));
1563
1564
__node_allocator& __na = __node_alloc ();
1564
1565
__node_traits::destroy (__na, std::addressof (__nd->__value_ ));
1565
1566
__node_traits::deallocate (__na, __nd, 1 );
@@ -1705,21 +1706,21 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__end_node_pointer& __parent, co
1705
1706
if (value_comp ()(__v, __nd->__value_ )) {
1706
1707
if (__nd->__left_ != nullptr ) {
1707
1708
__nd_ptr = std::addressof (__nd->__left_ );
1708
- __nd = static_cast <__node_pointer>(__nd->__left_ );
1709
+ __nd = std::__static_fancy_pointer_cast <__node_pointer>(__nd->__left_ );
1709
1710
} else {
1710
1711
__parent = static_cast <__end_node_pointer>(__nd);
1711
1712
return __parent->__left_ ;
1712
1713
}
1713
1714
} else if (value_comp ()(__nd->__value_ , __v)) {
1714
1715
if (__nd->__right_ != nullptr ) {
1715
1716
__nd_ptr = std::addressof (__nd->__right_ );
1716
- __nd = static_cast <__node_pointer>(__nd->__right_ );
1717
+ __nd = std::__static_fancy_pointer_cast <__node_pointer>(__nd->__right_ );
1717
1718
} else {
1718
1719
__parent = static_cast <__end_node_pointer>(__nd);
1719
1720
return __nd->__right_ ;
1720
1721
}
1721
1722
} else {
1722
- __parent = static_cast <__end_node_pointer>(__nd);
1723
+ __parent = std::__static_fancy_pointer_cast <__end_node_pointer>(__nd);
1723
1724
return *__nd_ptr;
1724
1725
}
1725
1726
}
@@ -1751,7 +1752,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(
1751
1752
return __parent->__left_ ;
1752
1753
} else {
1753
1754
__parent = __prior.__ptr_ ;
1754
- return static_cast <__node_base_pointer>(__prior.__ptr_ )->__right_ ;
1755
+ return std::__static_fancy_pointer_cast <__node_base_pointer>(__prior.__ptr_ )->__right_ ;
1755
1756
}
1756
1757
}
1757
1758
// __v <= *prev(__hint)
@@ -1788,7 +1789,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__insert_n
1788
1789
// __new_node->__is_black_ is initialized in __tree_balance_after_insert
1789
1790
__child = __new_node;
1790
1791
if (__begin_node ()->__left_ != nullptr )
1791
- __begin_node () = static_cast <__end_node_pointer>(__begin_node ()->__left_ );
1792
+ __begin_node () = std::__static_fancy_pointer_cast <__end_node_pointer>(__begin_node ()->__left_ );
1792
1793
std::__tree_balance_after_insert (__end_node ()->__left_ , __child);
1793
1794
++size ();
1794
1795
}
@@ -1910,7 +1911,8 @@ if(__libcpp_is_constant_evaluated()){
1910
1911
1911
1912
typename __tree<_Tp, _Compare, _Allocator>::__node_holder::pointer cast = static_cast <
1912
1913
__tree<_Tp, _Compare, _Allocator>::__node_holder::pointer>(__h.get ());
1913
- __node_base_pointer base = static_cast <__node_base_pointer>(cast);
1914
+ __node_base_pointer base = // static_cast<__node_base_pointer>(cast);
1915
+ std::__static_fancy_pointer_cast<__node_base_pointer>(cast);
1914
1916
1915
1917
1916
1918
__insert_node_at (__parent, __child, base);
0 commit comments