| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. | 2 * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. |
| 3 * All rights reserved. | 3 * All rights 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 } | 64 } |
| 65 | 65 |
| 66 template <typename T> | 66 template <typename T> |
| 67 class PassRefPtr { | 67 class PassRefPtr { |
| 68 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); | 68 DISALLOW_NEW_EXCEPT_PLACEMENT_NEW(); |
| 69 | 69 |
| 70 public: | 70 public: |
| 71 PassRefPtr() : m_ptr(nullptr) {} | 71 PassRefPtr() : m_ptr(nullptr) {} |
| 72 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} | 72 PassRefPtr(std::nullptr_t) : m_ptr(nullptr) {} |
| 73 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } | 73 PassRefPtr(T* ptr) : m_ptr(ptr) { refIfNotNull(ptr); } |
| 74 // It somewhat breaks the type system to allow transfer of ownership out of | |
| 75 // a const PassRefPtr. However, it makes it much easier to work with | |
| 76 // PassRefPtr temporaries, and we don't have a need to use real const | |
| 77 // PassRefPtrs anyway. | |
| 78 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} | |
| 79 PassRefPtr(PassRefPtr&& o) : m_ptr(o.leakRef()) {} | 74 PassRefPtr(PassRefPtr&& o) : m_ptr(o.leakRef()) {} |
| 80 template <typename U> | 75 template <typename U> |
| 81 PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) | 76 PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibleArgDecl(U, T)) |
| 82 : m_ptr(o.leakRef()) {} | 77 : m_ptr(o.leakRef()) {} |
| 83 | 78 |
| 84 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } | 79 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } |
| 85 | 80 |
| 86 template <typename U> | 81 template <typename U> |
| 87 PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T)); | 82 PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDecl(U, T)); |
| 88 template <typename U> | 83 template <typename U> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 inline T* getPtr(const PassRefPtr<T>& p) { | 214 inline T* getPtr(const PassRefPtr<T>& p) { |
| 220 return p.get(); | 215 return p.get(); |
| 221 } | 216 } |
| 222 | 217 |
| 223 } // namespace WTF | 218 } // namespace WTF |
| 224 | 219 |
| 225 using WTF::PassRefPtr; | 220 using WTF::PassRefPtr; |
| 226 using WTF::adoptRef; | 221 using WTF::adoptRef; |
| 227 | 222 |
| 228 #endif // WTF_PassRefPtr_h | 223 #endif // WTF_PassRefPtr_h |
| OLD | NEW |