diff options
Diffstat (limited to 'base/strings')
| -rw-r--r-- | base/strings/string16.h | 17 | ||||
| -rw-r--r-- | base/strings/string16_unittest.cc | 14 | ||||
| -rw-r--r-- | base/strings/string_piece.h | 6 |
3 files changed, 6 insertions, 31 deletions
diff --git a/base/strings/string16.h b/base/strings/string16.h index af44a5c..e47669c 100644 --- a/base/strings/string16.h +++ b/base/strings/string16.h @@ -29,8 +29,6 @@ #include <stddef.h> #include <stdint.h> #include <stdio.h> - -#include <functional> #include <string> #include "base/base_export.h" @@ -184,21 +182,6 @@ 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_ diff --git a/base/strings/string16_unittest.cc b/base/strings/string16_unittest.cc index 0d2ca80..4e58218 100644 --- a/base/strings/string16_unittest.cc +++ b/base/strings/string16_unittest.cc @@ -3,7 +3,6 @@ // found in the LICENSE file. #include <sstream> -#include <unordered_set> #include "base/strings/string16.h" @@ -12,6 +11,8 @@ namespace base { +#if defined(WCHAR_T_IS_UTF32) + // We define a custom operator<< for string16 so we can use it with logging. // This tests that conversion. TEST(String16Test, OutputStream) { @@ -52,15 +53,6 @@ TEST(String16Test, OutputStream) { } } -TEST(String16Test, Hash) { - string16 str1 = ASCIIToUTF16("hello"); - string16 str2 = ASCIIToUTF16("world"); - - std::unordered_set<string16> set; - - set.insert(str1); - EXPECT_EQ(1u, set.count(str1)); - EXPECT_EQ(0u, set.count(str2)); -} +#endif } // namespace base diff --git a/base/strings/string_piece.h b/base/strings/string_piece.h index 92634b9..31e7596 100644 --- a/base/strings/string_piece.h +++ b/base/strings/string_piece.h @@ -439,9 +439,9 @@ BASE_EXPORT std::ostream& operator<<(std::ostream& o, // We provide appropriate hash functions so StringPiece and StringPiece16 can // be used as keys in hash sets and maps. -// This hash function is copied from base/strings/string16.h. We don't use the -// ones already defined for string and string16 directly because it would -// require the string constructors to be called, which we don't want. +// This hash function is copied from base/containers/hash_tables.h. We don't +// use the ones already defined for string and string16 directly because it +// would require the string constructors to be called, which we don't want. #define HASH_STRING_PIECE(StringPieceType, string_piece) \ std::size_t result = 0; \ for (StringPieceType::const_iterator i = string_piece.begin(); \ |
