Counterintuitive std::pointer_traits rebind

François Dumont frs.dumont@gmail.com
Sat Jul 6 09:00:41 GMT 2024


On 05/07/2024 22:36, Jonathan Wakely wrote:
> On Fri, 5 Jul 2024 at 21:33, Jonathan Wakely <jwakely.gcc@gmail.com> wrote:
>> On Fri, 5 Jul 2024 at 21:09, François Dumont <frs.dumont@gmail.com> wrote:
>>> Hi
>>>
>>> I started to add support for allocator fancy pointer types in _Rb_tree
>>> and I wrote something like that:
>>>
>>>     template<typename _BasePtr, typename _BaseCPtr>
>>>       struct _Rb_tree_pnode_base
>>>       {
>>> #if __cplusplus < 201103L
>>>         typedef _BasePtr        _Base_ptr;
>>>         typedef _BaseCPtr    _Const_Base_ptr;
>>> #else
>>>         using _Base_ptr =
>>>       __ptr_rebind<_BasePtr, _Rb_tree_pnode_base>;
>>>         using _Const_Base_ptr =
>>>       __ptr_rebind<_BaseCPtr, _Rb_tree_pnode_base>;
>> This is wrong, it should rebind to const _Rb_tree_pnode_base.

Ok, good to know, I'll do it that way then.


>
> In any case, I don't think we can do fancy pointer support this way,
> it would be an ABI problem. If it was that easy, I would have done it
> years ago!
>
> I think we need to do something like
> https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57272#c4 so that we get
> completely different node types when fancy pointers are used, so
> mangled names change. Otherwise we'll get new node types which have
> the same mangled name but different layout if they now contain fancy
> pointers.

Yes, as I said in my initial email this is not what I've eventually done.

I'm mostly replicating what has been done in the proposal for hashtable.




More information about the Libstdc++ mailing list