| Index: base/strings/string16.h
|
| diff --git a/base/strings/string16.h b/base/strings/string16.h
|
| index e47669c1b565e7cb79bfc275eb5965a9e506cbdf..af44a5c5bf17a1ee6fd48bed9c794771b189b326 100644
|
| --- a/base/strings/string16.h
|
| +++ b/base/strings/string16.h
|
| @@ -29,6 +29,8 @@
|
| #include <stddef.h>
|
| #include <stdint.h>
|
| #include <stdio.h>
|
| +
|
| +#include <functional>
|
| #include <string>
|
|
|
| #include "base/base_export.h"
|
| @@ -182,6 +184,21 @@ 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. Although the style guide forbids
|
| +// this in general, it is necessary for consistency with WCHAR_T_IS_UTF16
|
| +// platforms, where base::string16 is a type alias for 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_
|
|
|