Navigation
API > API/Runtime > API/Runtime/Core > API/Runtime/Core/Templates
References
| Module | Core |
| Header | /Engine/Source/Runtime/Core/Public/Templates/SharedPointer.h |
| Include | #include "Templates/SharedPointer.h" |
template<typename InObjectType, ESPMode InMode, typename... InArgTypes>
TSharedRef < InObjectType, InMode > MakeShared
(
InArgTypes &&... Args
)
Remarks
MakeShared utility function. Allocates a new ObjectType and reference controller in a single memory block. Equivalent to std::make_shared.
NOTE: If the constructor is private/protected you will need to utilize a private token. Do not make SharedPointerInternals::TIntrusiveReferenceController a friend. class FMyType { private: struct FPrivateToken { explicit FPrivateToken() = default; };
public: // This has an equivalent access level to a private constructor, // as only friends of FMyType will have access to FPrivateToken, // but MakeShared can legally call it since it's public. explicit FMyType(FPrivateToken, int32 Int, float Real, const TCHAR* String); };
// Won't compile if the caller doesn't have access to FMyType::FPrivateToken
TSharedPtr