Use Unreal vs. Std smart pointers?

I’m trying to understand if there’s an advantage/disadvantage of using standard C++ smart pointers (std::shared_ptr, std::unique_ptr, etc.) vs. the Unreal implementation of smart pointers (TSharedPtr, TUniquePtr, etc.) For C++ modules in Unreal. Thanks in advance for your help.

Just wanted to refresh this. Does anyone have an opinion on this? Thanks.

Generally speaking, if an architecture implements their own versions it’s best to stick to those as a default as they usually don’t do it for fun.

That said, for UE I believe using theirs gives their reflection system better tracking and management of resources. Akin to using their TObjectPtr versus a raw pointer.

1 Like

Unreal’s implementation is integrated with their garbage collection/memory management systems. This is usually an enough advantage to many developers.

1 Like

IMHO there is zero reason to use any STD anything including pointers for UObjects. You lose garbage collection, UPROPERTY(), map serialization, etc.

For non-UObject stuff its fine though.

Thanks. To clarify, I meant using smart pointers for the non UObjects. I realize that UObjects already have garbage collection built in.

1 Like

Sure then. We have a custom TCP system that has lots of STD stuff. But we very strictly keep anything STD inside that code. No creep is allowed. :+1:

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.