OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2009, 2010 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 typedef T ValueType; | 43 typedef T ValueType; |
44 typedef ValueType* PtrType; | 44 typedef ValueType* PtrType; |
45 | 45 |
46 PassOwnPtr() : m_ptr(0) { } | 46 PassOwnPtr() : m_ptr(0) { } |
47 PassOwnPtr(std::nullptr_t) : m_ptr(0) { } | 47 PassOwnPtr(std::nullptr_t) : m_ptr(0) { } |
48 | 48 |
49 // It somewhat breaks the type system to allow transfer of ownership out
of | 49 // It somewhat breaks the type system to allow transfer of ownership out
of |
50 // a const PassOwnPtr. However, it makes it much easier to work with Pas
sOwnPtr | 50 // a const PassOwnPtr. However, it makes it much easier to work with Pas
sOwnPtr |
51 // temporaries, and we don't have a need to use real const PassOwnPtrs a
nyway. | 51 // temporaries, and we don't have a need to use real const PassOwnPtrs a
nyway. |
52 PassOwnPtr(const PassOwnPtr& o) : m_ptr(o.leakPtr()) { } | 52 PassOwnPtr(const PassOwnPtr& o) : m_ptr(o.leakPtr()) { } |
53 template<typename U> PassOwnPtr(const PassOwnPtr<U>& o) : m_ptr(o.leakPt
r()) { } | 53 template<typename U> PassOwnPtr(const PassOwnPtr<U>& o, EnsurePtrConvert
ibleArgDecl(U, T)) : m_ptr(o.leakPtr()) { } |
54 | 54 |
55 ~PassOwnPtr() { deleteOwnedPtr(m_ptr); } | 55 ~PassOwnPtr() { deleteOwnedPtr(m_ptr); } |
56 | 56 |
57 PtrType get() const { return m_ptr; } | 57 PtrType get() const { return m_ptr; } |
58 | 58 |
59 PtrType leakPtr() const WARN_UNUSED_RETURN; | 59 PtrType leakPtr() const WARN_UNUSED_RETURN; |
60 | 60 |
61 ValueType& operator*() const { ASSERT(m_ptr); return *m_ptr; } | 61 ValueType& operator*() const { ASSERT(m_ptr); return *m_ptr; } |
62 PtrType operator->() const { ASSERT(m_ptr); return m_ptr; } | 62 PtrType operator->() const { ASSERT(m_ptr); return m_ptr; } |
63 | 63 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 162 } |
163 | 163 |
164 } // namespace WTF | 164 } // namespace WTF |
165 | 165 |
166 using WTF::PassOwnPtr; | 166 using WTF::PassOwnPtr; |
167 using WTF::adoptPtr; | 167 using WTF::adoptPtr; |
168 using WTF::const_pointer_cast; | 168 using WTF::const_pointer_cast; |
169 using WTF::static_pointer_cast; | 169 using WTF::static_pointer_cast; |
170 | 170 |
171 #endif // WTF_PassOwnPtr_h | 171 #endif // WTF_PassOwnPtr_h |
OLD | NEW |