Flutter Engine
The Flutter Engine
ref_ptr_internal.h
Go to the documentation of this file.
1// Copyright 2013 The Flutter 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 FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_
6#define FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_
7
8#include <utility>
9
10#include "flutter/fml/macros.h"
11
12namespace fml {
13
14template <typename T>
15class RefPtr;
16
17template <typename T>
18RefPtr<T> AdoptRef(T* ptr);
19
20namespace internal {
21
22// This is a wrapper class that can be friended for a particular |T|, if you
23// want to make |T|'s constructor private, but still use |MakeRefCounted()|
24// (below). (You can't friend partial specializations.) See |MakeRefCounted()|
25// and |FML_FRIEND_MAKE_REF_COUNTED()|.
26template <typename T>
28 public:
29 template <typename... Args>
30 static RefPtr<T> MakeRefCounted(Args&&... args) {
31 return AdoptRef<T>(new T(std::forward<Args>(args)...));
32 }
33};
34
35} // namespace internal
36} // namespace fml
37
38#endif // FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_
static RefPtr< T > MakeRefCounted(Args &&... args)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
Definition: ascii_trie.cc:9
RefPtr< T > AdoptRef(T *ptr)
Definition: ref_ptr.h:222
#define T
Definition: precompiler.cc:65