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 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 explicit PassRefPtr(T& ptr) : m_ptr(&ptr) { m_ptr->ref(); } | 67 explicit PassRefPtr(T& ptr) : m_ptr(&ptr) { m_ptr->ref(); } |
68 // It somewhat breaks the type system to allow transfer of ownership out of | 68 // It somewhat breaks the type system to allow transfer of ownership out of |
69 // a const PassRefPtr. However, it makes it much easier to work with | 69 // a const PassRefPtr. However, it makes it much easier to work with |
70 // PassRefPtr temporaries, and we don't have a need to use real const | 70 // PassRefPtr temporaries, and we don't have a need to use real const |
71 // PassRefPtrs anyway. | 71 // PassRefPtrs anyway. |
72 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} | 72 PassRefPtr(const PassRefPtr& o) : m_ptr(o.leakRef()) {} |
73 PassRefPtr(const PassRefPtr&& o) : m_ptr(o.leakRef()) {} | |
Yuta Kitamura
2016/08/24 08:26:22
Remove "const" here. It's confusing to have "const
Bugs Nash
2016/08/29 01:50:24
Done.
| |
73 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl eArgDecl(U, T)) : m_ptr(o.leakRef()) {} | 74 template <typename U> PassRefPtr(const PassRefPtr<U>& o, EnsurePtrConvertibl eArgDecl(U, T)) : m_ptr(o.leakRef()) {} |
74 | 75 |
75 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } | 76 ALWAYS_INLINE ~PassRefPtr() { derefIfNotNull(m_ptr); } |
76 | 77 |
77 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe cl(U, T)); | 78 template <typename U> PassRefPtr(const RefPtr<U>&, EnsurePtrConvertibleArgDe cl(U, T)); |
78 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T)); | 79 template <typename U> PassRefPtr(RefPtr<U>&&, EnsurePtrConvertibleArgDecl(U, T)); |
79 | 80 |
80 T* get() const { return m_ptr; } | 81 T* get() const { return m_ptr; } |
81 | 82 |
82 T* leakRef() const WARN_UNUSED_RETURN; | 83 T* leakRef() const WARN_UNUSED_RETURN; |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
209 { | 210 { |
210 return p.get(); | 211 return p.get(); |
211 } | 212 } |
212 | 213 |
213 } // namespace WTF | 214 } // namespace WTF |
214 | 215 |
215 using WTF::PassRefPtr; | 216 using WTF::PassRefPtr; |
216 using WTF::adoptRef; | 217 using WTF::adoptRef; |
217 | 218 |
218 #endif // WTF_PassRefPtr_h | 219 #endif // WTF_PassRefPtr_h |
OLD | NEW |