OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser
ved. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reser
ved. |
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 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 62 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
63 public: | 63 public: |
64 PassRefPtr() : m_ptr(nullptr) {} | 64 PassRefPtr() : m_ptr(nullptr) {} |
65 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} | 65 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} |
66 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 66 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
67 // It somewhat breaks the type system to allow transfer of ownership out of | 67 // It somewhat breaks the type system to allow transfer of ownership out of |
68 // a const PassRefPtr. However, it makes it much easier to work with | 68 // a const PassRefPtr. However, it makes it much easier to work with |
69 // PassRefPtr temporaries, and we don't have a need to use real const | 69 // PassRefPtr temporaries, and we don't have a need to use real const |
70 // PassRefPtrs anyway. | 70 // PassRefPtrs anyway. |
71 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} | 71 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} |
| 72 PassRefPtr(PassRefPtr&& o) : m_ptr(o.leakRef()) {} |
72 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl
eArgDecl(U, T)) : m_ptr(o.leakRef()) {} | 73 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl
eArgDecl(U, T)) : m_ptr(o.leakRef()) {} |
73 | 74 |
74 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } | 75 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } |
75 | 76 |
76 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe
cl(U, T)); | 77 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe
cl(U, T)); |
77 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U,
T)); | 78 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U,
T)); |
78 | 79 |
79 T* get() const { return m_ptr; } | 80 T* get() const { return m_ptr; } |
80 | 81 |
81 T* leakRef() const WARN_UNUSED_RETURN; | 82 T* leakRef() const WARN_UNUSED_RETURN; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
208 { | 209 { |
209 return p.get(); | 210 return p.get(); |
210 } | 211 } |
211 | 212 |
212 } // namespace WTF | 213 } // namespace WTF |
213 | 214 |
214 using WTF::PassRefPtr; | 215 using WTF::PassRefPtr; |
215 using WTF::adoptRef; | 216 using WTF::adoptRef; |
216 | 217 |
217 #endif // WTF_PassRefPtr_h | 218 #endif // WTF_PassRefPtr_h |
OLD | NEW |