Passing Arbitrary Data to a Function

I think I found a solution using StructUtils / FInstancedStruct. I would appreciate any knowledgeable person’s advice if this is actually better than just sending UObjects as EventArgs.

Assuming the signature:

void(TSubclassOf<UEventType> EventClass, UObject* Sender, FInstancedStruct& EventArgs);

Evoke the event using:

FMyDerivedEventArgs newEventArgs;
FInstancedStruct wrapper = FInstancedStruct::Make(newEventArgs);
BroadcastEvent(EventClass, Sender, wrapper);

In the receiving function, attempt to get a pointer to the correct type:

if (const FMyDerivedEventArgs* AsDerivedType = EventArgs.GetPtr<FMyDerivedEventArgs>())
{
    DoSomething();
}
else
{
    // Not the correct EventArgs type
}