How to avoid pointer to struct when something can be null

As always, it all depends.
What will be in this structure, where and how and how often it will be used.

TOptional<T> has its limitations, but frequently allocating/deallocating small object is also not a good idea.
If you need use UObject-stuff then much better is to add a bool flag and hold one instance than juggling NewObject/nullptr pair.

2 Likes