OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. | 2 * Copyright (C) 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved. |
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 24 matching lines...) Expand all Loading... |
35 | 35 |
36 template<typename T> class PassOwnPtr; | 36 template<typename T> class PassOwnPtr; |
37 template<typename T> PassOwnPtr<T> adoptPtr(T*); | 37 template<typename T> PassOwnPtr<T> adoptPtr(T*); |
38 | 38 |
39 template<typename T> class OwnPtr { | 39 template<typename T> class OwnPtr { |
40 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) | 40 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) |
41 // If rvalue references are not supported, the copy constructor is | 41 // If rvalue references are not supported, the copy constructor is |
42 // public so OwnPtr cannot be marked noncopyable. See note below. | 42 // public so OwnPtr cannot be marked noncopyable. See note below. |
43 WTF_MAKE_NONCOPYABLE(OwnPtr); | 43 WTF_MAKE_NONCOPYABLE(OwnPtr); |
44 #endif | 44 #endif |
| 45 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(OwnPtr); |
45 public: | 46 public: |
46 typedef typename RemovePointer<T>::Type ValueType; | 47 typedef typename RemovePointer<T>::Type ValueType; |
47 typedef ValueType* PtrType; | 48 typedef ValueType* PtrType; |
48 | 49 |
49 OwnPtr() : m_ptr(0) { } | 50 OwnPtr() : m_ptr(0) { } |
50 OwnPtr(std::nullptr_t) : m_ptr(0) { } | 51 OwnPtr(std::nullptr_t) : m_ptr(0) { } |
51 | 52 |
52 // See comment in PassOwnPtr.h for why this takes a const reference. | 53 // See comment in PassOwnPtr.h for why this takes a const reference. |
53 template<typename U> OwnPtr(const PassOwnPtr<U>& o); | 54 template<typename U> OwnPtr(const PassOwnPtr<U>& o); |
54 | 55 |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr<
T>& p) | 212 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr<
T>& p) |
212 { | 213 { |
213 return p.get(); | 214 return p.get(); |
214 } | 215 } |
215 | 216 |
216 } // namespace WTF | 217 } // namespace WTF |
217 | 218 |
218 using WTF::OwnPtr; | 219 using WTF::OwnPtr; |
219 | 220 |
220 #endif // WTF_OwnPtr_h | 221 #endif // WTF_OwnPtr_h |
OLD | NEW |