Why should I replace raw pointers with TObjectPtr?

@Navhkrin

Well the most basic and fundamental incentive for doing so is because Epic has decided to adopt this standard for pointers

Sure, that’s very apparent. However, consider these three snippets from the migration guide:

TObjectPtr … an optional replacement for raw object pointers in editor builds

Although it is optional, we recommend using TObjectPtr<T> over T*

TObjectPtr … may improve your experience when developing in editor builds

So, the gist of what I’ve found out is its not mandatory (this is apparent since my build still runs without adding them), and it ‘may’ help interacting with the editor (I’m interested in this). I just would really like to know some more details to motivate me to make this change.

2 Likes