What this tutorial covers
- Why Unreal Engine throws this error
- The underlying restriction in
UPROPERTYand reflection - Correct ways to use
TArrayinsideTMap - Working fixes with
USTRUCTwrapping - Alternative patterns when nesting containers fails
The problem
You may encounter an error like:
Or when writing code like:
TMap<int32, TArray<int32>> MyMap;
This fails even though both TMap and TArray are valid Unreal containers.
Why this happens
This is not a C++ limitation.
It is a Unreal Header Tool (UHT) and reflection system restriction.
Key rule:
UPROPERTYdoes not support nested container types directly.
Specifically:
TMap<Key, Value>is supportedTArray<Type>is supported- ❌
TMap<Key, TArray<Type>>is not supported as a reflected property
This happens because:
- Unreal’s reflection system represents containers using
FPropertytypes TArraybecomesFArrayPropertyTMapbecomesFMapProperty
But:
Unreal does not allow
FArrayPropertyto be used as the value property insideFMapProperty
So UHT throws:
Important distinction
Important distinction
This restriction only applies when using:
UPROPERTY()
or from Blueprint authoured maps.
This works (no reflection):
TMap<int32, TArray<int32>> MyMap;
This fails (reflection enabled):
UPROPERTY()
TMap<int32, TArray<int32>> MyMap;
The correct solution: Wrap the array in a USTRUCT
Instead of storing TArray directly, wrap it in a struct.
Step 1 — Define a struct
USTRUCT()
struct FIntArrayWrapper
{
GENERATED_BODY()
UPROPERTY()
TArray Values;
};
Step 2 — Use it inside TMap
UPROPERTY()
TMap MyMap;
Why this works
Now Unreal sees:
TMap<Key, Struct>→ valid- Struct contains
TArray→ valid
This avoids the unsupported container-inside-container reflection case.
Common variations of this error
You may also see:
ArrayProperty cannot be used as a value in a TMapNested containers are not supported- Errors when using
TSet<TArray<...>> - Errors when exposing nested containers to Blueprints
They all stem from the same restriction.
Summary
- This is a reflection system limitation, not a C++ issue
TMap<Key, TArray<Value>>is invalid with UPROPERTY- The correct fix is to wrap the array inside a USTRUCT
- Alternatively, remove
UPROPERTYif reflection is not needed