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

Side by Side Diff: base/hash_tables.h

Issue 20041: Make possible using pointer as a hash_table key when compiling using GCC. (Closed)
Patch Set: Created 11 years, 10 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 | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 5
6 // 6 //
7 // Deal with the differences between Microsoft and GNU implemenations 7 // Deal with the differences between Microsoft and GNU implemenations
8 // of hash_map. Allows all platforms to use |base::hash_map| and 8 // of hash_map. Allows all platforms to use |base::hash_map| and
9 // |base::hash_set|. 9 // |base::hash_set|.
10 // eg: 10 // eg:
11 // base::hash_map<int> my_map; 11 // base::hash_map<int> my_map;
12 // base::hash_set<int> my_set; 12 // base::hash_set<int> my_set;
13 // 13 //
14 14
15 #ifndef BASE_HASH_TABLES_H__ 15 #ifndef BASE_HASH_TABLES_H__
16 #define BASE_HASH_TABLES_H__ 16 #define BASE_HASH_TABLES_H__
17 17
18 #include "build/build_config.h" 18 #include "build/build_config.h"
19 19
20 #if defined(COMPILER_MSVC) 20 #if defined(COMPILER_MSVC)
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 size_t operator()(const std::string& s) const { 70 size_t operator()(const std::string& s) const {
71 return std::tr1::hash<std::string>()(s); 71 return std::tr1::hash<std::string>()(s);
72 } 72 }
73 }; 73 };
74 74
75 template<> 75 template<>
76 struct hash<const std::string> { 76 struct hash<const std::string> {
77 size_t operator()(const std::string& s) const { 77 size_t operator()(const std::string& s) const {
78 return std::tr1::hash<std::string>()(s); 78 return std::tr1::hash<std::string>()(s);
79 } 79 }
80 }; 80 };
81
82 template<typename T>
83 struct hash<T*> {
84 size_t operator()(T* s) const {
85 return std::tr1::hash<T*>()(s);
86 }
87 };
88
89 template<typename T>
90 struct hash<const T*> {
91 size_t operator()(const T* s) const {
92 return std::tr1::hash<const T*>()(s);
93 }
94 };
81 95
82 } 96 }
83 97
84 #endif 98 #endif
85 99
86 #endif // BASE_HASH_TABLES_H__ 100 #endif // BASE_HASH_TABLES_H__
87 101
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698