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

Side by Side Diff: tools/gn/label.h

Issue 612323010: Align base::hash_map with C++11. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Try a different tack for C++ insanity Created 6 years, 2 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
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 TOOLS_GN_LABEL_H_ 5 #ifndef TOOLS_GN_LABEL_H_
6 #define TOOLS_GN_LABEL_H_ 6 #define TOOLS_GN_LABEL_H_
7 7
8 #include "base/containers/hash_tables.h" 8 #include "base/containers/hash_tables.h"
9 #include "build/build_config.h" 9 #include "build/build_config.h"
10 #include "tools/gn/source_dir.h" 10 #include "tools/gn/source_dir.h"
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 private: 100 private:
101 SourceDir dir_; 101 SourceDir dir_;
102 std::string name_; 102 std::string name_;
103 103
104 SourceDir toolchain_dir_; 104 SourceDir toolchain_dir_;
105 std::string toolchain_name_; 105 std::string toolchain_name_;
106 }; 106 };
107 107
108 namespace BASE_HASH_NAMESPACE { 108 namespace BASE_HASH_NAMESPACE {
109 109
110 #if defined(COMPILER_GCC)
111 template<> struct hash<Label> { 110 template<> struct hash<Label> {
112 std::size_t operator()(const Label& v) const { 111 std::size_t operator()(const Label& v) const {
113 hash<std::string> stringhash; 112 hash<std::string> stringhash;
114 return ((stringhash(v.dir().value()) * 131 + 113 return ((stringhash(v.dir().value()) * 131 +
115 stringhash(v.name())) * 131 + 114 stringhash(v.name())) * 131 +
116 stringhash(v.toolchain_dir().value())) * 131 + 115 stringhash(v.toolchain_dir().value())) * 131 +
117 stringhash(v.toolchain_name()); 116 stringhash(v.toolchain_name());
118 } 117 }
119 }; 118 };
120 #elif defined(COMPILER_MSVC)
121 inline size_t hash_value(const Label& v) {
122 return ((hash_value(v.dir().value()) * 131 +
123 hash_value(v.name())) * 131 +
124 hash_value(v.toolchain_dir().value())) * 131 +
125 hash_value(v.toolchain_name());
126 }
127 #endif // COMPILER...
128 119
129 } // namespace BASE_HASH_NAMESPACE 120 } // namespace BASE_HASH_NAMESPACE
130 121
131 inline void swap(Label& lhs, Label& rhs) { 122 inline void swap(Label& lhs, Label& rhs) {
132 lhs.swap(rhs); 123 lhs.swap(rhs);
133 } 124 }
134 125
135 #endif // TOOLS_GN_LABEL_H_ 126 #endif // TOOLS_GN_LABEL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698