This snippet compiled for me. Will report back if it works in real-time.
static TMap<FString, int32> TestVar = {
{"5", 5},
{"3", 3}
};
Update 1
- has made a [nice wiki-post][1] for this.
- My previous snippet seemed to somehow work.
**Full code**
Header file:
UCLASS(Abstract, Blueprintable)
class PROT_API AYourClass: public AActor
{
GENERATED_BODY()
public:
AYourClass();
protected:
static const TMap<FString, int32> TestVar;
};
Source file:
const TMap<FString, int32> AYourClass::TestVar = {
{"5", 5},
{"3", 3}
};
AYourClass::AYourClass()
{
bAutoDestroyWhenFinished = true;
for (const auto& Entry : TestVar)
{
UE_LOG(LogTemp, Warning, TEXT("-- %d"), Entry.Value);
}
}
**Update 2**
I do understand it is not exactly what question is about yet it might help other people.