|
40 | 40 | #include <__utility/forward.h>
|
41 | 41 | #include <__utility/move.h>
|
42 | 42 | #include <__utility/pair.h>
|
| 43 | +#include <__utility/pointer_int_pair.h> |
43 | 44 | #include <__utility/swap.h>
|
44 | 45 | #include <limits>
|
45 | 46 |
|
@@ -654,6 +655,45 @@ public:
|
654 | 655 | __tree_node_base& operator=(__tree_node_base const&) = delete;
|
655 | 656 | };
|
656 | 657 |
|
| 658 | +#ifdef _LIBCPP_ABI_TREE_POINTER_INT_PAIR |
| 659 | +template <> |
| 660 | +class __tree_node_base< void*> : public __tree_node_base_types<void*>::__end_node_type { |
| 661 | + using _NodeBaseTypes = __tree_node_base_types<void*>; |
| 662 | + |
| 663 | +public: |
| 664 | + using pointer = typename _NodeBaseTypes::__node_base_pointer; |
| 665 | + using __parent_pointer = typename _NodeBaseTypes::__parent_pointer; |
| 666 | + |
| 667 | + pointer __right_; |
| 668 | + |
| 669 | +private: |
| 670 | + using __pair_t = __pointer_int_pair<__parent_pointer, bool, __integer_width(1)>; |
| 671 | + |
| 672 | + __pair_t __parent_and_color_; |
| 673 | + |
| 674 | +public: |
| 675 | + _LIBCPP_HIDE_FROM_ABI pointer __parent_unsafe() const { |
| 676 | + return static_cast<pointer>(__parent_and_color_.__get_ptr()); |
| 677 | + } |
| 678 | + |
| 679 | + _LIBCPP_HIDE_FROM_ABI void __set_parent(pointer __ptr) { __set_parent(static_cast<__parent_pointer>(__ptr)); } |
| 680 | + |
| 681 | + _LIBCPP_HIDE_FROM_ABI void __set_parent(__parent_pointer __ptr) { |
| 682 | + __parent_and_color_ = __pair_t(__ptr, __parent_and_color_.__get_value()); |
| 683 | + } |
| 684 | + |
| 685 | + _LIBCPP_HIDE_FROM_ABI __parent_pointer __get_parent() const { return __parent_and_color_.__get_ptr(); } |
| 686 | + _LIBCPP_HIDE_FROM_ABI __tree_color __get_color() const { |
| 687 | + return static_cast<__tree_color>(__parent_and_color_.__get_value()); |
| 688 | + } |
| 689 | + _LIBCPP_HIDE_FROM_ABI void __set_color(__tree_color __color) { |
| 690 | + __parent_and_color_ = __pair_t(__parent_and_color_.__get_ptr(), __color == __tree_color::__black); |
| 691 | + } |
| 692 | +}; |
| 693 | +#endif // _LIBCPP_ABI_TREE_POINTER_INT_PAIR |
| 694 | + |
| 695 | +static_assert(sizeof(__tree_node_base<void*>) == 24); |
| 696 | + |
657 | 697 | template <class _Tp, class _VoidPtr>
|
658 | 698 | class _LIBCPP_STANDALONE_DEBUG __tree_node : public __tree_node_base<_VoidPtr> {
|
659 | 699 | public:
|
|
0 commit comments