blob: b38f943751854cd6765e3e18ed89c2f06131c2d0 [file] [log] [blame]
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_
#define FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_
#include <utility>
#include "flutter/fml/macros.h"
namespace fml {
template <typename T>
class RefPtr;
template <typename T>
RefPtr<T> AdoptRef(T* ptr);
namespace internal {
// This is a wrapper class that can be friended for a particular |T|, if you
// want to make |T|'s constructor private, but still use |MakeRefCounted()|
// (below). (You can't friend partial specializations.) See |MakeRefCounted()|
// and |FML_FRIEND_MAKE_REF_COUNTED()|.
template <typename T>
class MakeRefCountedHelper final {
public:
template <typename... Args>
static RefPtr<T> MakeRefCounted(Args&&... args) {
return AdoptRef<T>(new T(std::forward<Args>(args)...));
}
};
} // namespace internal
} // namespace fml
#endif // FLUTTER_FML_MEMORY_REF_PTR_INTERNAL_H_