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

Side by Side Diff: Source/wtf/HashTraits.h

Issue 185903002: HashTraits<RawPtr> uses 'nullptr' (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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 /* 1 /*
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed. 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights reserv ed.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 typedef PassRefPtr<P> PassOutType; 184 typedef PassRefPtr<P> PassOutType;
185 static PassOutType passOut(RefPtr<P>& value) { return value.release(); } 185 static PassOutType passOut(RefPtr<P>& value) { return value.release(); }
186 static PassOutType passOut(std::nullptr_t) { return nullptr; } 186 static PassOutType passOut(std::nullptr_t) { return nullptr; }
187 187
188 typedef P* PeekOutType; 188 typedef P* PeekOutType;
189 static PeekOutType peek(const RefPtr<P>& value) { return value.get(); } 189 static PeekOutType peek(const RefPtr<P>& value) { return value.get(); }
190 static PeekOutType peek(std::nullptr_t) { return 0; } 190 static PeekOutType peek(std::nullptr_t) { return 0; }
191 }; 191 };
192 192
193 template<typename T> struct HashTraits<RawPtr<T> > : SimpleClassHashTraits<R awPtr<T> > { 193 template<typename T> struct HashTraits<RawPtr<T> > : SimpleClassHashTraits<R awPtr<T> > {
194 typedef std::nullptr_t EmptyValueType;
195 static EmptyValueType emptyValue() { return nullptr; }
196
197 static const bool hasIsEmptyValueFunction = true;
198 static bool isEmptyValue(const RawPtr<T>& value) { return !value; }
199
194 static const bool needsDestruction = false; 200 static const bool needsDestruction = false;
195 typedef T* PeekInType; 201 typedef T* PeekInType;
196 typedef T* PassInType; 202 typedef T* PassInType;
197 typedef RawPtr<T>* IteratorGetType; 203 typedef RawPtr<T>* IteratorGetType;
198 typedef const RawPtr<T>* IteratorConstGetType; 204 typedef const RawPtr<T>* IteratorConstGetType;
199 typedef RawPtr<T>& IteratorReferenceType; 205 typedef RawPtr<T>& IteratorReferenceType;
200 typedef T* const IteratorConstReferenceType; 206 typedef T* const IteratorConstReferenceType;
201 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; } 207 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { return *x; }
202 static IteratorConstReferenceType getToReferenceConstConversion(Iterator ConstGetType x) { return x->get(); } 208 static IteratorConstReferenceType getToReferenceConstConversion(Iterator ConstGetType x) { return x->get(); }
203 typedef T* PeekOutType; 209 typedef T* PeekOutType;
204 typedef T* PassOutType; 210 typedef T* PassOutType;
205 211
206 template<typename U> 212 template<typename U>
207 static void store(const U& value, RawPtr<T>& storage) { storage = value; } 213 static void store(const U& value, RawPtr<T>& storage) { storage = value; }
208 214
209 static PeekOutType peek(const RawPtr<T>& value) { return value; } 215 static PeekOutType peek(const RawPtr<T>& value) { return value; }
216 static PeekOutType peek(std::nullptr_t) { return 0; }
217
210 static PassOutType passOut(const RawPtr<T>& value) { return value; } 218 static PassOutType passOut(const RawPtr<T>& value) { return value; }
219 static PassOutType passOut(std::nullptr_t) { return 0; }
211 }; 220 };
212 221
213 template<> struct HashTraits<String> : SimpleClassHashTraits<String> { 222 template<> struct HashTraits<String> : SimpleClassHashTraits<String> {
214 static const bool hasIsEmptyValueFunction = true; 223 static const bool hasIsEmptyValueFunction = true;
215 static bool isEmptyValue(const String&); 224 static bool isEmptyValue(const String&);
216 }; 225 };
217 226
218 // This struct template is an implementation detail of the isHashTraitsEmpty Value function, 227 // This struct template is an implementation detail of the isHashTraitsEmpty Value function,
219 // which selects either the emptyValue function or the isEmptyValue function to check for empty values. 228 // which selects either the emptyValue function or the isEmptyValue function to check for empty values.
220 template<typename Traits, bool hasEmptyValueFunction> struct HashTraitsEmpty ValueChecker; 229 template<typename Traits, bool hasEmptyValueFunction> struct HashTraitsEmpty ValueChecker;
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 }; 317 };
309 318
310 } // namespace WTF 319 } // namespace WTF
311 320
312 using WTF::HashTraits; 321 using WTF::HashTraits;
313 using WTF::PairHashTraits; 322 using WTF::PairHashTraits;
314 using WTF::NullableHashTraits; 323 using WTF::NullableHashTraits;
315 using WTF::SimpleClassHashTraits; 324 using WTF::SimpleClassHashTraits;
316 325
317 #endif // WTF_HashTraits_h 326 #endif // WTF_HashTraits_h
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