Chromium Code Reviews| 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 * Copyright (C) 2013 Intel Corporation. All rights reserved. | 3 * Copyright (C) 2013 Intel Corporation. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 57 ~PassOwnPtr() { OwnedPtrDeleter<T>::deletePtr(m_ptr); } | 57 ~PassOwnPtr() { OwnedPtrDeleter<T>::deletePtr(m_ptr); } |
| 58 | 58 |
| 59 PtrType get() const { return m_ptr; } | 59 PtrType get() const { return m_ptr; } |
| 60 | 60 |
| 61 PtrType leakPtr() const WARN_UNUSED_RETURN; | 61 PtrType leakPtr() const WARN_UNUSED_RETURN; |
| 62 | 62 |
| 63 ValueType& operator*() const { ASSERT(m_ptr); return *m_ptr; } | 63 ValueType& operator*() const { ASSERT(m_ptr); return *m_ptr; } |
| 64 PtrType operator->() const { ASSERT(m_ptr); return m_ptr; } | 64 PtrType operator->() const { ASSERT(m_ptr); return m_ptr; } |
| 65 | 65 |
| 66 bool operator!() const { return !m_ptr; } | 66 bool operator!() const { return !m_ptr; } |
| 67 | 67 explicit operator bool() const { return m_ptr; } |
|
danakj
2016/04/12 23:23:24
ditto?
| |
| 68 // This conversion operator allows implicit conversion to bool but not to | |
| 69 // other integer types. | |
| 70 typedef PtrType PassOwnPtr::*UnspecifiedBoolType; | |
| 71 operator UnspecifiedBoolType() const { return m_ptr ? &PassOwnPtr::m_ptr : 0 ; } | |
| 72 | 68 |
| 73 template <typename U> friend PassOwnPtr<U> adoptPtr(U*); | 69 template <typename U> friend PassOwnPtr<U> adoptPtr(U*); |
| 74 template <typename U> friend PassOwnPtr<U[]> adoptArrayPtr(U*); | 70 template <typename U> friend PassOwnPtr<U[]> adoptArrayPtr(U*); |
| 75 template <typename U> friend class OwnPtr; | 71 template <typename U> friend class OwnPtr; |
| 76 | 72 |
| 77 private: | 73 private: |
| 78 explicit PassOwnPtr(PtrType ptr) : m_ptr(ptr) {} | 74 explicit PassOwnPtr(PtrType ptr) : m_ptr(ptr) {} |
| 79 | 75 |
| 80 PassOwnPtr& operator=(const PassOwnPtr&) = delete; | 76 PassOwnPtr& operator=(const PassOwnPtr&) = delete; |
| 81 | 77 |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 146 } | 142 } |
| 147 | 143 |
| 148 } // namespace WTF | 144 } // namespace WTF |
| 149 | 145 |
| 150 using WTF::PassOwnPtr; | 146 using WTF::PassOwnPtr; |
| 151 using WTF::adoptPtr; | 147 using WTF::adoptPtr; |
| 152 using WTF::adoptArrayPtr; | 148 using WTF::adoptArrayPtr; |
| 153 using WTF::static_pointer_cast; | 149 using WTF::static_pointer_cast; |
| 154 | 150 |
| 155 #endif // WTF_PassOwnPtr_h | 151 #endif // WTF_PassOwnPtr_h |
| OLD | NEW |