On Tue, 8 Oct 2024 at 22:50, Jonathan Wakely <jwakely....@gmail.com> wrote:

>
>
> On Thu, 1 Aug 2024 at 18:28, François Dumont <frs.dum...@gmail.com> wrote:
>
>> Hi
>>
>> Here is a proposal to add fancy pointer support in std::_Rb_tree
>> container.
>>
>> As you'll see there are still several usages of
>> pointer_traits<>::pointer_to. The ones in _M_header_ptr() are
>> unavoidable.
>
>
> Yes, those are necessary.
>
> The pointer_to use in _M_const_cast could be simplified by adding a
> _M_self_ptr() member to _Rb_tree_pnode_base:
>
>   _Base_ptr
>   _M_self_ptr() _GLIBCXX_NOEXCEPT
>   { return pointer_traits<_Base_ptr>::pointer_to(*this); }
>
>   _Base_ptr
>   _M_self_ptr_nc() const _GLIBCXX_NOEXCEPT
>   {
>     auto __self = const_cast<_Rb_tree_pnode_base*>(this);
>     return __self->_M_self_ptr();
>   }
>


You might not even need this const overload:


>
>  _Const_Base_ptr
>   _M_self_ptr() const _GLIBCXX_NOEXCEPT
>   { return pointer_traits<_Const_Base_ptr>::pointer_to(*this); }
>
>
>

Reply via email to