This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: hash_map<> and string...
- To: libstdc++ at sources dot redhat dot com
- Subject: Re: hash_map<> and string...
- From: Benjamin Kosnik <bkoz at redhat dot com>
- Date: Tue, 21 Nov 2000 13:07:48 -0800
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