Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: Source/wtf/PassOwnPtr.h

Issue 23531003: Type check when upcasting PassOwnPtr/PassOwnArrayPtr to avoid possible function call ambiguousness (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 typedef typename RemovePointer<T>::Type ValueType; 45 typedef typename RemovePointer<T>::Type ValueType;
46 typedef ValueType* PtrType; 46 typedef ValueType* PtrType;
47 47
48 PassOwnPtr() : m_ptr(0) { } 48 PassOwnPtr() : m_ptr(0) { }
49 PassOwnPtr(std::nullptr_t) : m_ptr(0) { } 49 PassOwnPtr(std::nullptr_t) : m_ptr(0) { }
50 50
51 // 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
52 // 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
53 // 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.
54 PassOwnPtr(const PassOwnPtr& o) : m_ptr(o.leakPtr()) { } 54 PassOwnPtr(const PassOwnPtr& o) : m_ptr(o.leakPtr()) { }
55 template<typename U> PassOwnPtr(const PassOwnPtr<U>& o) : m_ptr(o.leakPt r()) { } 55 template<typename U> PassOwnPtr(const PassOwnPtr<U>& o, EnsureOwnPtrConv ertibleArgDecl) : m_ptr(o.leakPtr()) { }
56 56
57 ~PassOwnPtr() { deleteOwnedPtr(m_ptr); } 57 ~PassOwnPtr() { deleteOwnedPtr(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
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 } 164 }
165 165
166 } // namespace WTF 166 } // namespace WTF
167 167
168 using WTF::PassOwnPtr; 168 using WTF::PassOwnPtr;
169 using WTF::adoptPtr; 169 using WTF::adoptPtr;
170 using WTF::const_pointer_cast; 170 using WTF::const_pointer_cast;
171 using WTF::static_pointer_cast; 171 using WTF::static_pointer_cast;
172 172
173 #endif // WTF_PassOwnPtr_h 173 #endif // WTF_PassOwnPtr_h
OLDNEW
« no previous file with comments | « Source/wtf/PassOwnArrayPtr.h ('k') | Source/wtf/PassRefPtr.h » ('j') | Source/wtf/PassRefPtr.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698