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

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

Issue 23960005: WTF::OwnPtr should behave similarly with the rest of WTF smart pointers (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
« no previous file with comments | « Source/web/PageOverlay.cpp ('k') | Source/wtf/PassOwnPtr.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 12 matching lines...) Expand all
23 23
24 #include "wtf/Assertions.h" 24 #include "wtf/Assertions.h"
25 #include "wtf/Noncopyable.h" 25 #include "wtf/Noncopyable.h"
26 #include "wtf/NullPtr.h" 26 #include "wtf/NullPtr.h"
27 #include "wtf/OwnPtrCommon.h" 27 #include "wtf/OwnPtrCommon.h"
28 #include "wtf/TypeTraits.h" 28 #include "wtf/TypeTraits.h"
29 #include <algorithm> 29 #include <algorithm>
30 30
31 namespace WTF { 31 namespace WTF {
32 32
33 // Unlike most of our smart pointers, OwnPtr can take either the pointer typ e or the pointed-to type.
34
35 template<typename T> class PassOwnPtr; 33 template<typename T> class PassOwnPtr;
36 template<typename T> PassOwnPtr<T> adoptPtr(T*); 34 template<typename T> PassOwnPtr<T> adoptPtr(T*);
37 35
38 template<typename T> class OwnPtr { 36 template<typename T> class OwnPtr {
39 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) 37 #if COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
40 // If rvalue references are not supported, the copy constructor is 38 // If rvalue references are not supported, the copy constructor is
41 // public so OwnPtr cannot be marked noncopyable. See note below. 39 // public so OwnPtr cannot be marked noncopyable. See note below.
42 WTF_MAKE_NONCOPYABLE(OwnPtr); 40 WTF_MAKE_NONCOPYABLE(OwnPtr);
43 #endif 41 #endif
44 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(OwnPtr); 42 WTF_DISALLOW_CONSTRUCTION_FROM_ZERO(OwnPtr);
45 public: 43 public:
46 typedef typename RemovePointer<T>::Type ValueType; 44 typedef T ValueType;
abarth-chromium 2013/09/06 05:13:12 Is RemovePointer used anywhere else? Perhaps we c
47 typedef ValueType* PtrType; 45 typedef ValueType* PtrType;
48 46
49 OwnPtr() : m_ptr(0) { } 47 OwnPtr() : m_ptr(0) { }
50 OwnPtr(std::nullptr_t) : m_ptr(0) { } 48 OwnPtr(std::nullptr_t) : m_ptr(0) { }
51 49
52 // See comment in PassOwnPtr.h for why this takes a const reference. 50 // See comment in PassOwnPtr.h for why this takes a const reference.
53 template<typename U> OwnPtr(const PassOwnPtr<U>& o); 51 template<typename U> OwnPtr(const PassOwnPtr<U>& o);
54 52
55 #if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES) 53 #if !COMPILER_SUPPORTS(CXX_RVALUE_REFERENCES)
56 // This copy constructor is used implicitly by gcc when it generates 54 // This copy constructor is used implicitly by gcc when it generates
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr< T>& p) 213 template<typename T> inline typename OwnPtr<T>::PtrType getPtr(const OwnPtr< T>& p)
216 { 214 {
217 return p.get(); 215 return p.get();
218 } 216 }
219 217
220 } // namespace WTF 218 } // namespace WTF
221 219
222 using WTF::OwnPtr; 220 using WTF::OwnPtr;
223 221
224 #endif // WTF_OwnPtr_h 222 #endif // WTF_OwnPtr_h
OLDNEW
« no previous file with comments | « Source/web/PageOverlay.cpp ('k') | Source/wtf/PassOwnPtr.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698