#pragma once #include "WeakObjectPtr.h" #include "Object.h" #include "PointerIsConvertibleFromTo.h" template struct TWeakObjectPtr; template struct TWeakObjectPtr : public TWeakObjectPtrBase { T* Get() { return (T*)TWeakObjectPtrBase::Get(); } /* bool operator==(const TWeakObjectPtr& other) { return TWeakObjectPtrBase::operator==(other); } */ TWeakObjectPtr() {} }; template FORCENOINLINE bool operator==(const TWeakObjectPtr& Lhs, const RhsT* Rhs) { // It's also possible that these static_asserts may fail for valid conversions because // one or both of the types have only been forward-declared. static_assert(TPointerIsConvertibleFromTo::Value, "TWeakObjectPtr can only be compared with UObject types"); static_assert(TPointerIsConvertibleFromTo::Value || TPointerIsConvertibleFromTo::Value, "Unable to compare TWeakObjectPtr with raw pointer - types are incompatible"); // NOTE: this constructs a TWeakObjectPtrBase, which has some amount of overhead, so this may not be an efficient operation return (const OtherTWeakObjectPtrBase&)Lhs == OtherTWeakObjectPtrBase(Rhs); } template FORCENOINLINE bool operator==(const LhsT* Lhs, const TWeakObjectPtr& Rhs) { // It's also possible that these static_asserts may fail for valid conversions because // one or both of the types have only been forward-declared. static_assert(TPointerIsConvertibleFromTo::Value, "TWeakObjectPtr can only be compared with UObject types"); static_assert(TPointerIsConvertibleFromTo::Value || TPointerIsConvertibleFromTo::Value, "Unable to compare TWeakObjectPtr with raw pointer - types are incompatible"); // NOTE: this constructs a TWeakObjectPtrBase, which has some amount of overhead, so this may not be an efficient operation return OtherTWeakObjectPtrBase(Lhs) == (const OtherTWeakObjectPtrBase&)Rhs; } template FORCENOINLINE bool operator==(const TWeakObjectPtr& Lhs, TYPE_OF_NULLPTR) { return !Lhs.IsValid(); } template FORCENOINLINE bool operator==(TYPE_OF_NULLPTR, const TWeakObjectPtr& Rhs) { return !Rhs.IsValid(); }