TMap < FString, FString > Add Causing Crash

Hi,

I am trying to create a simple TMap < FString, FString >.

In my header file, I have this:

TMap<FString, FString> MyMap;

In my cpp file, I have this:

MyMap.Add("Key", "Value");

And it crashes at this line everytime.

Here is the line it is crashing on after add is called:

TSet<TTuple<FString,FString>,TDefaultMapHashableKeyFuncs<FString,FString,0>,FDefaultSetAllocator>::Emplace<TPairInitializer<FString && __ptr64,FString && __ptr64> >() [c:\users\nicho\documents\unreal projects\ue-source\engine\source\runtime\core\public\containers\set.h:488]

The class I am using is a subclass of UObject which I create via NewObject<>. I have tried the same line in My Game Instance and it works fine. I have also tried adding UPROPERTY() above it and I have tried to initialize in the constructor. All to no avail. Any ideas as to what is happening or where I have gone wrong?

Try using TEXT(“StringHere”) instead. Also, I tend to use emplace on maps, but it depends how you want the add to function, and whether you want it to overwrite previous entries.

Thanks, turns out something was corrupted. I recreated my UObject file and now it works as expected with no crash.