From ebe77d7e3bdd6c39522fceab23a87b4e1b697b77 Mon Sep 17 00:00:00 2001 From: mmentovai Date: Thu, 20 Aug 2009 19:29:41 +0000 Subject: 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 --- src/common/mac/dwarf/functioninfo.cc | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/common/mac/dwarf/functioninfo.cc b/src/common/mac/dwarf/functioninfo.cc index b6d3f0fe..267d6cf9 100644 --- a/src/common/mac/dwarf/functioninfo.cc +++ b/src/common/mac/dwarf/functioninfo.cc @@ -39,14 +39,25 @@ #include "common/mac/dwarf/bytereader.h" -namespace __gnu_cxx -{ - template<> - struct hash - { - 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 . It is duplicated here because GCC versions prior to +// 4.3.2 are unable to compile when RTTI is disabled, as it +// may be in this code. + +template<> +struct hash { + 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 { -- cgit v1.2.1