| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef MOJO_EDK_SYSTEM_REF_PTR_INTERNAL_H_ | |
| 6 #define MOJO_EDK_SYSTEM_REF_PTR_INTERNAL_H_ | |
| 7 | |
| 8 #include <utility> | |
| 9 | |
| 10 #include "mojo/public/cpp/system/macros.h" | |
| 11 | |
| 12 namespace mojo { | |
| 13 namespace system { | |
| 14 | |
| 15 template <typename T> | |
| 16 class RefPtr; | |
| 17 | |
| 18 template <typename T> | |
| 19 RefPtr<T> AdoptRef(T* ptr); | |
| 20 | |
| 21 namespace internal { | |
| 22 | |
| 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()| | |
| 25 // (below). (You can't friend partial specializations.) See |MakeRefCounted()| | |
| 26 // and |FRIEND_MAKE_REF_COUNTED()|. | |
| 27 template <typename T> | |
| 28 class MakeRefCountedHelper { | |
| 29 public: | |
| 30 template <typename... Args> | |
| 31 static RefPtr<T> MakeRefCounted(Args&&... args) { | |
| 32 return AdoptRef<T>(new T(std::forward<Args>(args)...)); | |
| 33 } | |
| 34 }; | |
| 35 | |
| 36 } // namespace internal | |
| 37 } // namespace system | |
| 38 } // namespace mojo | |
| 39 | |
| 40 #endif // MOJO_EDK_SYSTEM_REF_PTR_INTERNAL_H_ | |
| OLD | NEW |