TEnumAsByte requires reference

I’m trying to create a TMap with an EPhysicalSurface key in the header file, issue is it obviously needs to be a reference, and “TEnumAsByte” returns a compile error saying: “Missing ‘>’ in TEnumAsByte”

I’ve tried to “#define EPhysicalSurface EPhysicalSurface*”, but because it’s in the header file and any calls to EPhysicalSurface in the .cpp are always a reference, so it works, but i cant do anything with it now. I did try to overwrite it with another define in the .cpp, but that just caused it to overwrite with the reference so it achieved litarelly nothing lol.

I’ve also tried to use a different enum in the TEnumAsByte<> but that causes the TMap to have the wrong enum key.
I feel like i’ve been here for an eternity, there has to be a way around this.

I’m not sure I know all the technical details; however, TMap values are not really pointers, but references, that’s why if you want to get a value, you use *, but then you can de-reference a value and use it as normal copy, not as a pointer.

I tried it on my custom Enum called EAction, and these both work fine:

TMap<EAction, FString> MyTMap;
TMap<TEnumAsByte<EAction>, FString> MyTMap;

It’s just when you want to get the value, you get the reference first:

FString* MyString1 = MyTMap.Find(ACT_Search);

and then you can de-reference the value:

FString MyString2 = *MyString1;

or simply de-reference it right away:

FString MyString3 = *MyTMap.Find(ACT_Search);
1 Like