Skip to content

Commit 1549261

Browse files
at.pass.cpp works
1 parent 7dfa7c1 commit 1549261

File tree

3 files changed

+20
-17
lines changed

3 files changed

+20
-17
lines changed

libcxx/include/__tree

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#ifndef _LIBCPP___TREE
1111
#define _LIBCPP___TREE
1212

13+
#include "__memory/pointer_traits.h"
1314
#include <__algorithm/min.h>
1415
#include <__assert>
1516
#include <__config>
@@ -569,11 +570,11 @@ public:
569570
bool __is_black_;
570571

571572
_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_);
573574
}
574575

575576
_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);
577578
}
578579

579580
// template <typename... Args> constexpr __tree_node_base(Args && ... args) =default;
@@ -702,7 +703,7 @@ public:
702703

703704
private:
704705
_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)) {}
706707
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_iterator(__end_node_pointer __p) _NOEXCEPT
707708
: __ptr_(__p) {}
708709
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 __node_pointer __get_np() const {
@@ -772,7 +773,7 @@ public:
772773
}
773774

774775
_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_));
776777
return *this;
777778
}
778779

@@ -797,7 +798,7 @@ private:
797798
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX26 explicit __tree_const_iterator(__end_node_pointer __p) _NOEXCEPT
798799
: __ptr_(__p) {}
799800
_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_);
801802
}
802803

803804
template <class, class, class>
@@ -923,7 +924,7 @@ public:
923924

924925
public:
925926
_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_);
927928
}
928929

929930
_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() {
15581559
template <class _Tp, class _Compare, class _Allocator>
15591560
_LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::destroy(__node_pointer __nd) _NOEXCEPT {
15601561
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_));
15631564
__node_allocator& __na = __node_alloc();
15641565
__node_traits::destroy(__na, std::addressof(__nd->__value_));
15651566
__node_traits::deallocate(__na, __nd, 1);
@@ -1705,21 +1706,21 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(__end_node_pointer& __parent, co
17051706
if (value_comp()(__v, __nd->__value_)) {
17061707
if (__nd->__left_ != nullptr) {
17071708
__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_);
17091710
} else {
17101711
__parent = static_cast<__end_node_pointer>(__nd);
17111712
return __parent->__left_;
17121713
}
17131714
} else if (value_comp()(__nd->__value_, __v)) {
17141715
if (__nd->__right_ != nullptr) {
17151716
__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_);
17171718
} else {
17181719
__parent = static_cast<__end_node_pointer>(__nd);
17191720
return __nd->__right_;
17201721
}
17211722
} else {
1722-
__parent = static_cast<__end_node_pointer>(__nd);
1723+
__parent = std::__static_fancy_pointer_cast<__end_node_pointer>(__nd);
17231724
return *__nd_ptr;
17241725
}
17251726
}
@@ -1751,7 +1752,7 @@ __tree<_Tp, _Compare, _Allocator>::__find_equal(
17511752
return __parent->__left_;
17521753
} else {
17531754
__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_;
17551756
}
17561757
}
17571758
// __v <= *prev(__hint)
@@ -1788,7 +1789,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 void __tree<_Tp, _Compare, _Allocator>::__insert_n
17881789
// __new_node->__is_black_ is initialized in __tree_balance_after_insert
17891790
__child = __new_node;
17901791
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_);
17921793
std::__tree_balance_after_insert(__end_node()->__left_, __child);
17931794
++size();
17941795
}
@@ -1910,7 +1911,8 @@ if(__libcpp_is_constant_evaluated()){
19101911

19111912
typename __tree<_Tp, _Compare, _Allocator>::__node_holder::pointer cast = static_cast<
19121913
__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);
19141916

19151917

19161918
__insert_node_at(__parent, __child, base);

libcxx/include/map

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1529,7 +1529,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 _Tp& map<_Key, _Tp, _Compare, _Allocator>::at(cons
15291529
__node_base_pointer& __child = __tree_.__find_equal(__parent, __k);
15301530
if (__child == nullptr)
15311531
std::__throw_out_of_range("map::at: key not found");
1532-
return static_cast<__node_pointer>(__child)->__value_.second;
1532+
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__value_.second;
15331533
}
15341534

15351535
template <class _Key, class _Tp, class _Compare, class _Allocator>
@@ -1538,7 +1538,7 @@ _LIBCPP_CONSTEXPR_SINCE_CXX26 const _Tp& map<_Key, _Tp, _Compare, _Allocator>::a
15381538
__node_base_pointer __child = __tree_.__find_equal(__parent, __k);
15391539
if (__child == nullptr)
15401540
std::__throw_out_of_range("map::at: key not found");
1541-
return static_cast<__node_pointer>(__child)->__value_.second;
1541+
return std::__static_fancy_pointer_cast<__node_pointer>(__child)->__value_.second;
15421542
}
15431543

15441544
template <class _Key, class _Tp, class _Compare, class _Allocator>

libcxx/test/support/min_allocator.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,8 @@ struct cpp03_overload_allocator : bare_allocator<T> {
163163
template <class T>
164164
bool cpp03_overload_allocator<T>::construct_called = false;
165165

166-
template <class T, class = std::integral_constant<std::size_t, 0> >
166+
// template <class T, class = std::integral_constant<std::size_t, 0> >
167+
template <class T, class = void >
167168
class min_pointer;
168169
template <class T, class ID>
169170
class min_pointer<const T, ID>;

0 commit comments

Comments
 (0)