This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: hash container unordered_map is defective for key='const char*', key='string' and key='const string'


Hi,
> Conclusion:
> * in my opinion we should add the specialization for 'char*' and 'const char*' to avoid unexpected results. also migration to the new container is much easier and performance much better.
>   
Well, we should consider that the current CD Standard (N2798) is rather
clear about this: at variance with the legacy hashed containers, there
is no concept of char array of C string, only of pointers. I don't think
the implementor can add a specialization for char* or const char*
comparing the pointed chars instead of the pointers themselves and
remain conforming.
> * specialization of hash<string> should not pass a string value but a reference instead.
>   
Again, the CD (20.7.1.7) is pretty clear about by-value.
> * if possible hash<string&> and hash<const string&> should be provided as inline code.
>   
Yes, probably. We'll see what we can do.
> * even with the additional specialization of hash<const char*> the new container is still a bit slower then the old one. (The performance is the same with compile option -DNDEBUG.)
>   
That is interesting but we badly need more specific hints, a bit of
profiling would probably help.

Paolo.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]