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

Side by Side Diff: mojo/edk/util/ref_ptr.h

Issue 1435043002: EDK: Sprinkle some more |final| secret sauce. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 years, 1 month 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 | « mojo/edk/util/mutex.h ('k') | mojo/edk/util/ref_ptr_internal.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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Provides a smart pointer class for intrusively reference-counted objects. 5 // Provides a smart pointer class for intrusively reference-counted objects.
6 6
7 #ifndef MOJO_EDK_UTIL_REF_PTR_H_ 7 #ifndef MOJO_EDK_UTIL_REF_PTR_H_
8 #define MOJO_EDK_UTIL_REF_PTR_H_ 8 #define MOJO_EDK_UTIL_REF_PTR_H_
9 9
10 #include <assert.h> 10 #include <assert.h>
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 // |U = T|, since the templated versions don't count as copy/move 56 // |U = T|, since the templated versions don't count as copy/move
57 // constructors/operator=s for the purposes of causing the default copy 57 // constructors/operator=s for the purposes of causing the default copy
58 // constructor/operator= to be deleted. E.g., if we didn't declare any 58 // constructor/operator= to be deleted. E.g., if we didn't declare any
59 // non-templated versions, we'd get the default copy constructor/operator= (we'd 59 // non-templated versions, we'd get the default copy constructor/operator= (we'd
60 // only not get the default move constructor/operator= by virtue of having a 60 // only not get the default move constructor/operator= by virtue of having a
61 // destructor)! (In fact, it'd suffice to only declare a non-templated move 61 // destructor)! (In fact, it'd suffice to only declare a non-templated move
62 // constructor or move operator=, which would cause the copy 62 // constructor or move operator=, which would cause the copy
63 // constructor/operator= to be deleted, but for clarity we include explicit 63 // constructor/operator= to be deleted, but for clarity we include explicit
64 // non-templated versions of everything.) 64 // non-templated versions of everything.)
65 template <typename T> 65 template <typename T>
66 class RefPtr { 66 class RefPtr final {
67 public: 67 public:
68 RefPtr() : ptr_(nullptr) {} 68 RefPtr() : ptr_(nullptr) {}
69 RefPtr(std::nullptr_t) : ptr_(nullptr) {} 69 RefPtr(std::nullptr_t) : ptr_(nullptr) {}
70 70
71 // Explicit constructor from a plain pointer (to an object that must have 71 // Explicit constructor from a plain pointer (to an object that must have
72 // already been adopted). (Note that in |T::T()|, references to |this| cannot 72 // already been adopted). (Note that in |T::T()|, references to |this| cannot
73 // be taken, since the object being constructed will not have been adopted 73 // be taken, since the object being constructed will not have been adopted
74 // yet.) 74 // yet.)
75 template <typename U> 75 template <typename U>
76 explicit RefPtr(U* p) 76 explicit RefPtr(U* p)
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 template <typename T, typename... Args> 224 template <typename T, typename... Args>
225 RefPtr<T> MakeRefCounted(Args&&... args) { 225 RefPtr<T> MakeRefCounted(Args&&... args) {
226 return internal::MakeRefCountedHelper<T>::MakeRefCounted( 226 return internal::MakeRefCountedHelper<T>::MakeRefCounted(
227 std::forward<Args>(args)...); 227 std::forward<Args>(args)...);
228 } 228 }
229 229
230 } // namespace util 230 } // namespace util
231 } // namespace mojo 231 } // namespace mojo
232 232
233 #endif // MOJO_EDK_UTIL_REF_PTR_H_ 233 #endif // MOJO_EDK_UTIL_REF_PTR_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/mutex.h ('k') | mojo/edk/util/ref_ptr_internal.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698