Download

passing TMap as function argument

I’m trying to pass a TMap object as a function argument

in myCode.h


FVector calculateVeloctiy(TArray<AActor*> inputArray, float deltaTime, TMap<int, TArray<int>> &inputDict);


inputArray is a list of all relevant objects.
inputDict has key-value pairs- basically the name of this object as keys, and values are names of objects that affect this’s velocity.
I can populate inputDict just fine elsewhere in my code, but when I try to add the TMap<int, TArray<int>> &inputDict part to this function call and compile I get an error: Error Nested containers are not supported.

Is there any way to pass a TMap that contains a TArray as the value?

As a raw C++ function yes you can do that, but not if it’s a UFUNCTION(). Reflection doesn’t support nested containers, so you will have to wrap the array with a USTRUCT then pass it in that way.

Also, you probably want to pass the containers by const ref:



FVector calculateVeloctiy(const TArray<AActor*>& inputArray, float deltaTime, const TMap<int32, TArray<int32>>& inputDict);


Thanks @TheJamsh , this is in fact a UFUNCTION(), which explains why i have the problem! I commented out the UFUNCTION flag above this line of code, and it compiles just fine!