unordered containers: reuse nodes on assignment
François Dumont
frs.dumont@gmail.com
Fri Jul 5 21:29:00 GMT 2013
Patch applied.
I also found the number of template parameters painful. Isolating a part
of the _Hashtable in a base class is a good idea and seems to be the
solution indeed, I will have a try.
François
On 07/05/2013 12:28 AM, Jonathan Wakely wrote:
> On 4 July 2013 21:54, François Dumont wrote:
>> And about the patch itself, is it ok ?
> Yes, that latest patch is OK, thanks.
>
> It's made me think about the design a bit more though ...
>
> I've been a little uncomfortable for some time with the number of
> template parameters that are needed everywhere in hashtable_policy.h.
> In most cases they seem necessary, but does the _ReuseOrAllocNode
> template really need 10 template parameters? Couldn't it just be
> passed the relevant _Hashtable type? Unfortunately with the current
> design it does seem necessary to know the full _Hashtable type, even
> though the functionality only really depends on the allocator type
> (and node and value types, but they can be obtained from the
> allocator.) That means if I instantiate unordered_set<T, H, P, A> and
> unordered_set<T, H2, P2, A> the compiler has to instantiate two
> different specializations of _ReuseOrAllocNode (and other code in
> _Hashtable) even though it doesn't care about the two function
> objects, and the executable is larger.
>
> Would it be possible to separate _M_node_allocator, _M_allocate_node,
> _M_deallocate_nodes and _M_deallocate_node into a separate base class
> of _Hashtable, and have _ReuseOrAllocNode only depend on that? That
> would allow unordered_set<T, H, P, A> and unordered_set<T, H2, P2, A>
> to share more code.
>
More information about the Libstdc++
mailing list