diff options
Diffstat (limited to 'src/common/mac')
-rw-r--r-- | src/common/mac/dwarf/functioninfo.cc | 27 |
1 files changed, 19 insertions, 8 deletions
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<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 { |