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 22 matching lines...) Expand all Loading... |
33 | 33 |
34 namespace WTF { | 34 namespace WTF { |
35 | 35 |
36 // Unlike most of our smart pointers, PassOwnPtr can take either the pointer
type or the pointed-to type. | 36 // Unlike most of our smart pointers, PassOwnPtr can take either the pointer
type or the pointed-to type. |
37 | 37 |
38 template<typename T> class OwnPtr; | 38 template<typename T> class OwnPtr; |
39 template<typename T> class PassOwnPtr; | 39 template<typename T> class PassOwnPtr; |
40 template<typename T> PassOwnPtr<T> adoptPtr(T*); | 40 template<typename T> PassOwnPtr<T> adoptPtr(T*); |
41 | 41 |
42 template<typename T> class PassOwnPtr { | 42 template<typename T> class PassOwnPtr { |
| 43 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(PassOwnPtr); |
43 public: | 44 public: |
44 typedef typename RemovePointer<T>::Type ValueType; | 45 typedef typename RemovePointer<T>::Type ValueType; |
45 typedef ValueType* PtrType; | 46 typedef ValueType* PtrType; |
46 | 47 |
47 PassOwnPtr() : m_ptr(0) { } | 48 PassOwnPtr() : m_ptr(0) { } |
48 PassOwnPtr(std::nullptr_t) : m_ptr(0) { } | 49 PassOwnPtr(std::nullptr_t) : m_ptr(0) { } |
49 | 50 |
50 // It somewhat breaks the type system to allow transfer of ownership out
of | 51 // It somewhat breaks the type system to allow transfer of ownership out
of |
51 // a const PassOwnPtr. However, it makes it much easier to work with Pas
sOwnPtr | 52 // a const PassOwnPtr. However, it makes it much easier to work with Pas
sOwnPtr |
52 // temporaries, and we don't have a need to use real const PassOwnPtrs a
nyway. | 53 // temporaries, and we don't have a need to use real const PassOwnPtrs a
nyway. |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
163 } | 164 } |
164 | 165 |
165 } // namespace WTF | 166 } // namespace WTF |
166 | 167 |
167 using WTF::PassOwnPtr; | 168 using WTF::PassOwnPtr; |
168 using WTF::adoptPtr; | 169 using WTF::adoptPtr; |
169 using WTF::const_pointer_cast; | 170 using WTF::const_pointer_cast; |
170 using WTF::static_pointer_cast; | 171 using WTF::static_pointer_cast; |
171 | 172 |
172 #endif // WTF_PassOwnPtr_h | 173 #endif // WTF_PassOwnPtr_h |
OLD | NEW |