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

Side by Side Diff: mojo/edk/util/ref_ptr_internal.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/ref_ptr.h ('k') | mojo/edk/util/waitable_event.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 #ifndef MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ 5 #ifndef MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_
6 #define MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ 6 #define MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_
7 7
8 #include <utility> 8 #include <utility>
9 9
10 #include "mojo/public/cpp/system/macros.h" 10 #include "mojo/public/cpp/system/macros.h"
11 11
12 namespace mojo { 12 namespace mojo {
13 namespace util { 13 namespace util {
14 14
15 template <typename T> 15 template <typename T>
16 class RefPtr; 16 class RefPtr;
17 17
18 template <typename T> 18 template <typename T>
19 RefPtr<T> AdoptRef(T* ptr); 19 RefPtr<T> AdoptRef(T* ptr);
20 20
21 namespace internal { 21 namespace internal {
22 22
23 // This is a wrapper class that can be friended for a particular |T|, if you 23 // This is a wrapper class that can be friended for a particular |T|, if you
24 // want to make |T|'s constructor private, but still use |MakeRefCounted()| 24 // want to make |T|'s constructor private, but still use |MakeRefCounted()|
25 // (below). (You can't friend partial specializations.) See |MakeRefCounted()| 25 // (below). (You can't friend partial specializations.) See |MakeRefCounted()|
26 // and |FRIEND_MAKE_REF_COUNTED()|. 26 // and |FRIEND_MAKE_REF_COUNTED()|.
27 template <typename T> 27 template <typename T>
28 class MakeRefCountedHelper { 28 class MakeRefCountedHelper final {
29 public: 29 public:
30 template <typename... Args> 30 template <typename... Args>
31 static RefPtr<T> MakeRefCounted(Args&&... args) { 31 static RefPtr<T> MakeRefCounted(Args&&... args) {
32 return AdoptRef<T>(new T(std::forward<Args>(args)...)); 32 return AdoptRef<T>(new T(std::forward<Args>(args)...));
33 } 33 }
34 }; 34 };
35 35
36 } // namespace internal 36 } // namespace internal
37 } // namespace util 37 } // namespace util
38 } // namespace mojo 38 } // namespace mojo
39 39
40 #endif // MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_ 40 #endif // MOJO_EDK_UTIL_REF_PTR_INTERNAL_H_
OLDNEW
« no previous file with comments | « mojo/edk/util/ref_ptr.h ('k') | mojo/edk/util/waitable_event.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698