hash_map<> and string...
Benjamin Kosnik
bkoz@redhat.com
Tue Nov 21 13:08:00 GMT 2000
Sorry for the delay, I'm going back through this newsgroup for things
I apparently forgot on the first pass.
------
The stl_hash_fun.h in CVS has:
inline size_t __stl_hash_string(const char* __s)
{
unsigned long __h = 0;
for ( ; *__s; ++__s)
__h = 5*__h + *__s;
return size_t(__h);
}
__STL_TEMPLATE_NULL struct hash<char*>
{
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
};
__STL_TEMPLATE_NULL struct hash<const char*>
{
size_t operator()(const char* __s) const { return __stl_hash_string(__s); }
};
I suspect this will get you where you want to go. If not, you're
pretty much out of luck, as only fundamental types are going in this
file, apparently.
Is it really that much extra work to define this yourself?
-benjamin
More information about the Libstdc++
mailing list