Why does TSTrongObjectPtr Move Constructor call Reset?

Hey UObject friends!

Looking at TStrongObjectPtr, I see

`template <typename ObjectType, typename ReferencerNameProvider>
class TStrongObjectPtr
{
public:
using ElementType = ObjectType;

TStrongObjectPtr(TStrongObjectPtr&& InOther)
{
Reset();
Object = InOther.Object;
InOther.Object = nullptr;
}`

Why does the Reset need to be there? If I understand correctly, the object is being constructed, so Object is already null (from the member variable initializer inline) so there’s no need to check for null / ReleaseRef.

on a similar note…shouldn’t we instead use an initializer in this constructor to set Object to avoid the unnecessary assignment to nullptr? I’d expect something like

TStrongObjectPtr(TStrongObjectPtr&& InOther) : Object(InOther.Object) { InOther.Object = nullptr; }

BUT very good chance I’m missing something!! What am I missing?

Hi Joshua,

I think you’re right and its just copy-pasta from TStrongObjectPtr& operator=(TStrongObjectPtr&& InOther)

Thanks for reporting

I’m going to go with your suggested change and make it reviewed here and submitted.

Best regards,

Danny

oh nice, thanks!