libstdc++ PR 57272 Fancy pointer support in Hashtable

Jonathan Wakely jwakely@redhat.com
Tue Oct 20 11:04:22 GMT 2020


On 28/09/20 22:37 +0200, François Dumont via Libstdc++ wrote:
>Following recent changes on _Hashtable I rebase the patch and 
>completely review it.
>
>I managed to integrate the allocator custom pointer type without 
>touching to _Hashtable base types like _Hash_code_base or 
>_Hashtable_base. However I cannot see how to use the custom pointer 
>type without impacting the node types like _Hash_node_base which now 
>takes a template parameter, the custom pointer type.
>
>On an abi point of view node types are different however the data 
>structure is the same. The only difference is that the _Hash_node_base 
>_M_nxt is now a _Hash_node<> custom pointer rather than a simple 
>_Hash_node_base*.
>
>Even if this patch can't go in because of the abi breaking change I am 
>going to adapt some of the code simplifications for master. Especially 
>the _Hash_code_base and _Local_iterator_base simplifications.
>
>Let me know if you can think of a way to integrate the custom pointer 
>without impacting abi. Unless impacting node types and associated 
>iterator types is fine even if I already noticed that pretty printer 
>tests are broken with those changes.

The approach I used for the other containers (which was never
completed and committed) is something like:

struct _Node_base
{
   _Node_base* _M_next;
};

template<typename _Ptr>
struct _Fancy_node_base
{
   _Ptr _M_next;
};

template<typename _Ptr>
   using node_base = conditional_t<is_pointer<_Ptr>::value,
                                   _Node_base,
                                   _Fancy_node_base<_Ptr>>;

This way all existing code that has allocators with non-fancy pointers
continues to use the same type. Code using fancy pointers (which
doesn't currently work properly anyway) changes to use the new types
that depend on the pointer type.



More information about the Libstdc++ mailing list