TWeakPtr::Reset
#include "Templates/SharedPointer.h"
Access: public
Specifiers: inline
Description
Removes this weak pointer's reference to the object by default-constructing a new empty TWeakPtr over itself. After Reset, IsValid() returns false.
Caveats & Gotchas
- • Reset assigns a freshly default-constructed TWeakPtr (not nullptr) — the implementation is `*this = TWeakPtr<ObjectType, Mode>()`, which releases the shared reference controller correctly and decrements the weak reference count.
- • If this was the last weak reference and there are no remaining shared references, the reference controller object itself is freed as a side effect of Reset.
Signature
UE_FORCEINLINE_HINT void Reset() Return Type
void Example
Clearing a cached weak reference C++
TWeakPtr<FMyService> WeakService;
void FMyClient::Disconnect()
{
WeakService.Reset();
check(!WeakService.IsValid());
} Tags
Version History
Introduced in: 4.0
| Version | Status | Notes |
|---|---|---|
| 5.6 | stable | — |
Feedback
Was this helpful?