unordered set design modification

François Dumont frs.dumont@gmail.com
Sun Oct 21 19:43:00 GMT 2012


On 10/21/2012 06:21 PM, Jonathan Wakely wrote:
> On 20 October 2012 22:07, François Dumont  wrote:
>> Hi
>>
>>      Following remarks in PR 53067 regarding design of unordered containers
> Which remarks specifically?
>
> My understanding was that Paolo's suggestion to redesign things was to
> avoid public inheritance, which we now do anyway.
>
>> here is a patch to prefer aggregation to inheritance with _Hashtable. I hope
>> it is what you had in mind Jonathan. If so I will do the same for
>> unordered_[multi]map.
> Are you referring to my comments in the "hashtable local iterator"
> thread last December?  Because IIRC my concern was about deriving from
> the user-supplied Hash and Pred types and this new patch doesn't alter
> that.  What is the advantage of this new patch?
>
> (Apologies if I'm forgetting some other suggestion of mine.)
>
> I think my concerns about deriving from user-supplied types are
> addressed by using the EBO helper (which prevents deriving from types
> with virtual functions, as the vptr makes the class non-empty) and by
> using private inheritance.
>
This patch is coming from this remark:

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52942#c4

You should be careful when you do remarks, they can have a strong impact ;-)

I fully agree with this remark just because for me encapsulation is a 
very important concept and aggregation offers better encapsulation than 
inheritance. This way unordered containers will expose only Standard 
methods. It doesn't fix any known issue at the moment even if this clean 
design would have avoid the 53067 issue.

François



More information about the Libstdc++ mailing list