|
41 | 41 | #include <__utility/forward.h>
|
42 | 42 | #include <__utility/move.h>
|
43 | 43 | #include <__utility/pair.h>
|
| 44 | +#include <__utility/pointer_int_pair.h> |
44 | 45 | #include <__utility/swap.h>
|
45 | 46 | #include <limits>
|
46 | 47 |
|
@@ -591,6 +592,43 @@ public:
|
591 | 592 | __tree_node_base& operator=(__tree_node_base const&) = delete;
|
592 | 593 | };
|
593 | 594 |
|
| 595 | +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR |
| 596 | +template <> |
| 597 | +class __tree_node_base<void*> : public __tree_end_node<__tree_node_base<void*>*> { |
| 598 | +public: |
| 599 | + using pointer = __tree_node_base<void*>*; |
| 600 | + using __end_node_pointer _LIBCPP_NODEBUG = __tree_end_node<__tree_node_base<void*>*>*; |
| 601 | + |
| 602 | + pointer __right_; |
| 603 | + |
| 604 | +private: |
| 605 | + using __pair_t = __pointer_int_pair<__end_node_pointer, bool, __integer_width(1)>; |
| 606 | + |
| 607 | + __pair_t __parent_and_color_; |
| 608 | + |
| 609 | +public: |
| 610 | + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { |
| 611 | + return static_cast<pointer>(__parent_and_color_.__get_ptr()); |
| 612 | + } |
| 613 | + |
| 614 | + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__end_node_pointer>(__ptr)); } |
| 615 | + |
| 616 | + _LIBCPP_HIDE_FROM_ABI void __set_parent(__end_node_pointer __ptr) { |
| 617 | + __parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); |
| 618 | + } |
| 619 | + |
| 620 | + _LIBCPP_HIDE_FROM_ABI __end_node_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } |
| 621 | + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { |
| 622 | + return static_cast<__tree_color>(__parent_and_color_.__get_value()); |
| 623 | + } |
| 624 | + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { |
| 625 | + __parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); |
| 626 | + } |
| 627 | +}; |
| 628 | +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR |
| 629 | + |
| 630 | +static_assert(sizeof(__tree_node_base<void*>) == 24); |
| 631 | + |
594 | 632 | template <class _Tp, class _VoidPtr>
|
595 | 633 | class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
|
596 | 634 | public:
|
|
0 commit comments