UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TRefCountingMixin< T, Mode > Class Template Reference

Detailed Description

template<typename T, ERefCountingMode Mode = ERefCountingMode::ThreadSafe>
class TRefCountingMixin< T, Mode >

Ref-counting mixin, designed to add ref-counting to an object without requiring a virtual destructor. Implements support for AutoRTFM, is thread-safe by default, and can support custom deleters via T::StaticDestroyObject.

Note
AutoRTFM means that the return value of AddRef/Release can't be trusted (as the ref-count doesn't decrement until the transaction is committed), but this is fine for use with TRefCountPtr, as it doesn't use those return values.

Basic Example: struct FMyRefCountedObject : public TRefCountingMixin<FMyRefCountedObject> { // ... };

Deleter Example: struct FMyRefCountedPooledObject : public TRefCountingMixin<FMyRefCountedPooledObject> { static void StaticDestroyObject(const FMyRefCountedPooledObject* Obj) { GPool->ReturnToPool(Obj); } };


The documentation for this class was generated from the following file: