This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug libstdc++/13342] hash_map doesn't support std::string keys
- From: "bkoz at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 9 Dec 2003 03:08:54 -0000
- Subject: [Bug libstdc++/13342] hash_map doesn't support std::string keys
- References: <20031207173222.13342.kgirard@connect.carleton.ca>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Additional Comments From bkoz at gcc dot gnu dot org 2003-12-09 03:08 -------
FYI we use hash strings in abi_check.cc. To do this, we do:
namespace __gnu_cxx
{
using namespace std;
template<>
struct hash<string>
{
size_t operator()(const string& s) const
{
const collate<char>& c = use_facet<collate<char> >(locale::classic());
return c.hash(s.c_str(), s.c_str() + s.size());
}
};
}
This is my preferred solution for hashing strings.
-benjamin
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13342