Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(259)

Side by Side Diff: base/strings/string16.h

Issue 1610023003: Revert of Allow std::unordered_*. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « base/location.h ('k') | base/strings/string16_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef BASE_STRINGS_STRING16_H_ 5 #ifndef BASE_STRINGS_STRING16_H_
6 #define BASE_STRINGS_STRING16_H_ 6 #define BASE_STRINGS_STRING16_H_
7 7
8 // WHAT: 8 // WHAT:
9 // A version of std::basic_string that provides 2-byte characters even when 9 // A version of std::basic_string that provides 2-byte characters even when
10 // wchar_t is not implemented as a 2-byte type. You can access this class as 10 // wchar_t is not implemented as a 2-byte type. You can access this class as
(...skipping 11 matching lines...) Expand all
22 // entirely improper on those systems where the encoding of wchar_t is defined 22 // entirely improper on those systems where the encoding of wchar_t is defined
23 // as UTF-32. 23 // as UTF-32.
24 // 24 //
25 // Here, we define string16, which is similar to std::wstring but replaces all 25 // Here, we define string16, which is similar to std::wstring but replaces all
26 // libc functions with custom, 2-byte-char compatible routines. It is capable 26 // libc functions with custom, 2-byte-char compatible routines. It is capable
27 // of carrying UTF-16-encoded data. 27 // of carrying UTF-16-encoded data.
28 28
29 #include <stddef.h> 29 #include <stddef.h>
30 #include <stdint.h> 30 #include <stdint.h>
31 #include <stdio.h> 31 #include <stdio.h>
32
33 #include <functional>
34 #include <string> 32 #include <string>
35 33
36 #include "base/base_export.h" 34 #include "base/base_export.h"
37 #include "build/build_config.h" 35 #include "build/build_config.h"
38 36
39 #if defined(WCHAR_T_IS_UTF16) 37 #if defined(WCHAR_T_IS_UTF16)
40 38
41 namespace base { 39 namespace base {
42 40
43 typedef wchar_t char16; 41 typedef wchar_t char16;
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 // in which the linker does not fully coalesce symbols when dead code 175 // in which the linker does not fully coalesce symbols when dead code
178 // stripping is enabled. This bug causes the memory errors described above 176 // stripping is enabled. This bug causes the memory errors described above
179 // to occur even when a std::basic_string<> does not cross shared library 177 // to occur even when a std::basic_string<> does not cross shared library
180 // boundaries, such as in statically-linked executables. 178 // boundaries, such as in statically-linked executables.
181 // 179 //
182 // TODO(mark): File this bug with Apple and update this note with a bug number. 180 // TODO(mark): File this bug with Apple and update this note with a bug number.
183 181
184 extern template 182 extern template
185 class BASE_EXPORT std::basic_string<base::char16, base::string16_char_traits>; 183 class BASE_EXPORT std::basic_string<base::char16, base::string16_char_traits>;
186 184
187 // Specialize std::hash for base::string16. Although the style guide forbids
188 // this in general, it is necessary for consistency with WCHAR_T_IS_UTF16
189 // platforms, where base::string16 is a type alias for std::wstring.
190 namespace std {
191 template<>
192 struct hash<base::string16> {
193 std::size_t operator()(const base::string16& s) const {
194 std::size_t result = 0;
195 for (base::char16 c : s)
196 result = (result * 131) + c;
197 return result;
198 }
199 };
200 } // namespace std
201
202 #endif // WCHAR_T_IS_UTF32 185 #endif // WCHAR_T_IS_UTF32
203 186
204 #endif // BASE_STRINGS_STRING16_H_ 187 #endif // BASE_STRINGS_STRING16_H_
OLDNEW
« no previous file with comments | « base/location.h ('k') | base/strings/string16_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698