OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2011, 2012 Apple Inc. All rights |
3 * reserved. | 3 * reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 IteratorConstGetType x) { | 216 IteratorConstGetType x) { |
217 return *x; | 217 return *x; |
218 } | 218 } |
219 | 219 |
220 static void Store(PassRefPtr<P> value, RefPtr<P>& storage) { | 220 static void Store(PassRefPtr<P> value, RefPtr<P>& storage) { |
221 storage = std::move(value); | 221 storage = std::move(value); |
222 } | 222 } |
223 | 223 |
224 typedef P* PeekOutType; | 224 typedef P* PeekOutType; |
225 static PeekOutType Peek(const RefPtr<P>& value) { return value.Get(); } | 225 static PeekOutType Peek(const RefPtr<P>& value) { return value.Get(); } |
226 static PeekOutType Peek(std::nullptr_t) { return 0; } | |
227 }; | 226 }; |
228 | 227 |
229 template <typename T> | 228 template <typename T> |
230 struct HashTraits<std::unique_ptr<T>> | 229 struct HashTraits<std::unique_ptr<T>> |
231 : SimpleClassHashTraits<std::unique_ptr<T>> { | 230 : SimpleClassHashTraits<std::unique_ptr<T>> { |
232 using EmptyValueType = std::nullptr_t; | 231 using EmptyValueType = std::nullptr_t; |
233 static EmptyValueType EmptyValue() { return nullptr; } | 232 static EmptyValueType EmptyValue() { return nullptr; } |
234 | 233 |
235 static const bool kHasIsEmptyValueFunction = true; | 234 static const bool kHasIsEmptyValueFunction = true; |
236 static bool IsEmptyValue(const std::unique_ptr<T>& value) { return !value; } | 235 static bool IsEmptyValue(const std::unique_ptr<T>& value) { return !value; } |
237 | 236 |
238 using PeekInType = T*; | 237 using PeekInType = T*; |
239 | 238 |
240 static void Store(std::unique_ptr<T>&& value, std::unique_ptr<T>& storage) { | 239 static void Store(std::unique_ptr<T>&& value, std::unique_ptr<T>& storage) { |
241 storage = std::move(value); | 240 storage = std::move(value); |
242 } | 241 } |
243 | 242 |
244 using PeekOutType = T*; | 243 using PeekOutType = T*; |
245 static PeekOutType Peek(const std::unique_ptr<T>& value) { | 244 static PeekOutType Peek(const std::unique_ptr<T>& value) { |
246 return value.get(); | 245 return value.get(); |
247 } | 246 } |
248 static PeekOutType Peek(std::nullptr_t) { return nullptr; } | |
249 | 247 |
250 static void ConstructDeletedValue(std::unique_ptr<T>& slot, bool) { | 248 static void ConstructDeletedValue(std::unique_ptr<T>& slot, bool) { |
251 // Dirty trick: implant an invalid pointer to unique_ptr. Destructor isn't | 249 // Dirty trick: implant an invalid pointer to unique_ptr. Destructor isn't |
252 // called for deleted buckets, so this is okay. | 250 // called for deleted buckets, so this is okay. |
253 new (NotNull, &slot) std::unique_ptr<T>(reinterpret_cast<T*>(1u)); | 251 new (NotNull, &slot) std::unique_ptr<T>(reinterpret_cast<T*>(1u)); |
254 } | 252 } |
255 static bool IsDeletedValue(const std::unique_ptr<T>& value) { | 253 static bool IsDeletedValue(const std::unique_ptr<T>& value) { |
256 return value.get() == reinterpret_cast<T*>(1u); | 254 return value.get() == reinterpret_cast<T*>(1u); |
257 } | 255 } |
258 }; | 256 }; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
420 }; | 418 }; |
421 | 419 |
422 } // namespace WTF | 420 } // namespace WTF |
423 | 421 |
424 using WTF::HashTraits; | 422 using WTF::HashTraits; |
425 using WTF::PairHashTraits; | 423 using WTF::PairHashTraits; |
426 using WTF::NullableHashTraits; | 424 using WTF::NullableHashTraits; |
427 using WTF::SimpleClassHashTraits; | 425 using WTF::SimpleClassHashTraits; |
428 | 426 |
429 #endif // WTF_HashTraits_h | 427 #endif // WTF_HashTraits_h |
OLD | NEW |