Provide a real std::string hash, not just a forward declaration for something

that doesn't exist.

TBR=nealsid

Code review URL: http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/292f9ed79dfdbdde


git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@391 4c0a9323-5329-0410-9bdc-e9ce6186880e
This commit is contained in:
mmentovai 2009-08-20 19:29:41 +00:00
parent b0baafc4da
commit ebe77d7e3b

View File

@ -39,14 +39,25 @@
#include "common/mac/dwarf/bytereader.h"
namespace __gnu_cxx
{
template<>
struct hash<std::string>
{
size_t operator()(const std::string& k) const;
};
}
namespace __gnu_cxx {
// Implement a string hash function so that std::string can be used as a key
// in STL maps and sets. The hash algorithm comes from the GNU C++ library,
// in <tr1/functional>. It is duplicated here because GCC versions prior to
// 4.3.2 are unable to compile <tr1/functional> when RTTI is disabled, as it
// may be in this code.
template<>
struct hash<std::string> {
std::size_t operator()(const std::string& s) const {
std::size_t result = 0;
for (std::string::const_iterator i = s.begin(); i != s.end(); ++i)
result = (result * 131) + *i;
return result;
}
};
} // namespace __gnu_cxx
namespace dwarf2reader {