OLD | NEW |
---|---|
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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
100 typedef T* IteratorGetType; | 100 typedef T* IteratorGetType; |
101 typedef const T* IteratorConstGetType; | 101 typedef const T* IteratorConstGetType; |
102 typedef T& IteratorReferenceType; | 102 typedef T& IteratorReferenceType; |
103 typedef const T& IteratorConstReferenceType; | 103 typedef const T& IteratorConstReferenceType; |
104 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; } | 104 static IteratorReferenceType getToReferenceConversion(IteratorGetType x) { r eturn *x; } |
105 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; } | 105 static IteratorConstReferenceType getToReferenceConstConversion(IteratorCons tGetType x) { return *x; } |
106 // Type for functions that take ownership, such as add. | 106 // Type for functions that take ownership, such as add. |
107 // The store function either not be called or called once to store something | 107 // The store function either not be called or called once to store something |
108 // passed in. The value passed to the store function will be PassInType. | 108 // passed in. The value passed to the store function will be PassInType. |
109 typedef const T& PassInType; | 109 typedef const T& PassInType; |
110 static void store(const T& value, T& storage) { storage = value; } | 110 template <typename IncomingValueType> |
111 static void store(IncomingValueType&& value, T& storage) { storage = std::fo rward<IncomingValueType>(value); } | |
111 | 112 |
112 // Type for return value of functions that transfer ownership, such as take. | 113 // Type for return value of functions that transfer ownership, such as take. |
113 typedef T PassOutType; | 114 typedef T PassOutType; |
114 static const T& passOut(const T& value) { return value; } | 115 static T&& passOut(T& value) { return std::move(value); } |
Mikhail
2016/03/04 12:58:02
do we still need 'passOut'? can std::move be calle
Yuta Kitamura
2016/03/04 13:55:37
Other specializations (for e.g. PassRefPtr) still
| |
116 static T&& passOut(T&& value) { return std::move(value); } | |
115 | 117 |
116 // Type for return value of functions that do not transfer ownership, such | 118 // Type for return value of functions that do not transfer ownership, such |
117 // as get. | 119 // as get. |
118 // FIXME: We could change this type to const T& for better performance if we | 120 // FIXME: We could change this type to const T& for better performance if we |
119 // figured out a way to handle the return value from emptyValue, which is a | 121 // figured out a way to handle the return value from emptyValue, which is a |
120 // temporary. | 122 // temporary. |
121 typedef T PeekOutType; | 123 typedef T PeekOutType; |
122 static const T& peek(const T& value) { return value; } | 124 static const T& peek(const T& value) { return value; } |
123 }; | 125 }; |
124 | 126 |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
257 static bool isDeletedValue(const TraitType& value) { return FirstTraits::isD eletedValue(value.first); } | 259 static bool isDeletedValue(const TraitType& value) { return FirstTraits::isD eletedValue(value.first); } |
258 }; | 260 }; |
259 | 261 |
260 template <typename First, typename Second> | 262 template <typename First, typename Second> |
261 struct HashTraits<std::pair<First, Second>> : public PairHashTraits<HashTraits<F irst>, HashTraits<Second>> { }; | 263 struct HashTraits<std::pair<First, Second>> : public PairHashTraits<HashTraits<F irst>, HashTraits<Second>> { }; |
262 | 264 |
263 template <typename KeyTypeArg, typename ValueTypeArg> | 265 template <typename KeyTypeArg, typename ValueTypeArg> |
264 struct KeyValuePair { | 266 struct KeyValuePair { |
265 typedef KeyTypeArg KeyType; | 267 typedef KeyTypeArg KeyType; |
266 | 268 |
267 KeyValuePair(const KeyTypeArg& _key, const ValueTypeArg& _value) | 269 template <typename IncomingKeyType, typename IncomingValueType> |
268 : key(_key) | 270 KeyValuePair(IncomingKeyType&& key, IncomingValueType&& value) |
269 , value(_value) | 271 : key(std::forward<IncomingKeyType>(key)) |
272 , value(std::forward<IncomingValueType>(value)) | |
270 { | 273 { |
271 } | 274 } |
272 | 275 |
273 template <typename OtherKeyType, typename OtherValueType> | 276 template <typename OtherKeyType, typename OtherValueType> |
274 KeyValuePair(KeyValuePair<OtherKeyType, OtherValueType>&& other) | 277 KeyValuePair(KeyValuePair<OtherKeyType, OtherValueType>&& other) |
275 : key(std::move(other.key)) | 278 : key(std::move(other.key)) |
276 , value(std::move(other.value)) | 279 , value(std::move(other.value)) |
277 { | 280 { |
278 } | 281 } |
279 | 282 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
335 struct TraceInCollectionTrait; | 338 struct TraceInCollectionTrait; |
336 | 339 |
337 } // namespace WTF | 340 } // namespace WTF |
338 | 341 |
339 using WTF::HashTraits; | 342 using WTF::HashTraits; |
340 using WTF::PairHashTraits; | 343 using WTF::PairHashTraits; |
341 using WTF::NullableHashTraits; | 344 using WTF::NullableHashTraits; |
342 using WTF::SimpleClassHashTraits; | 345 using WTF::SimpleClassHashTraits; |
343 | 346 |
344 #endif // WTF_HashTraits_h | 347 #endif // WTF_HashTraits_h |
OLD | NEW |