| Index: base/strings/string16.h
|
| diff --git a/base/strings/string16.h b/base/strings/string16.h
|
| index ba4ffe788a48ec10470c5417a862aa172e9c6f0a..b16468ded1afe4617fe05d5c7128e0ea33888e1a 100644
|
| --- a/base/strings/string16.h
|
| +++ b/base/strings/string16.h
|
| @@ -27,6 +27,8 @@
|
| // of carrying UTF-16-encoded data.
|
|
|
| #include <stdio.h>
|
| +
|
| +#include <functional>
|
| #include <string>
|
|
|
| #include "base/base_export.h"
|
| @@ -180,6 +182,20 @@ BASE_EXPORT extern void PrintTo(const string16& str, std::ostream* out);
|
| extern template
|
| class BASE_EXPORT std::basic_string<base::char16, base::string16_char_traits>;
|
|
|
| +// Specialize std::hash for base::string16 for consistency with WCHAR_T_IS_UTF16
|
| +// platforms, where base::string16 is std::wstring.
|
| +namespace std {
|
| +template<>
|
| +struct hash<base::string16> {
|
| + std::size_t operator()(const base::string16& s) const {
|
| + std::size_t result = 0;
|
| + for (base::char16 c : s)
|
| + result = (result * 131) + c;
|
| + return result;
|
| + }
|
| +};
|
| +} // namespace std
|
| +
|
| #endif // WCHAR_T_IS_UTF32
|
|
|
| #endif // BASE_STRINGS_STRING16_H_
|
|
|