Hi.
I’m trying to cast a FUniqueNetIdPtr (or FUniqueNetId&) to void* and later on, in a callback, cast it back to original type, to use it. How could I possibly do this? It won’t accept reinterpret_cast, or (void*), nor StaticCast.
Hi.
I’m trying to cast a FUniqueNetIdPtr (or FUniqueNetId&) to void* and later on, in a callback, cast it back to original type, to use it. How could I possibly do this? It won’t accept reinterpret_cast, or (void*), nor StaticCast.
If you are sure that the object being sent outlives callback then you can send the address of variable.
For example:
struct FSomething
{
FUniqueNetIdPtr NetIdPtr;
void DoWork()
{
FString SomeData = PrepareData();
Callback(SomeData, &NetIdPtr);
}
};
void Callback(FString const& InData, void* InPtr)
{
auto NetPtr = static_cast<FNetUniqueIdPtr*>(InPtr);
if (NetPtr->GetSize() == InData.Num()) {
//...
}
}