Is it wise to have a pointer to a member of a TMap/TArray?

I have a custom struct that I am storing in a TMap within another TMap.

Is it wise to use a pointer to access this member or should I be concerned about Unreal moving this data around even if I do not make edits to the structure of the arrays?

You can do it in C ( C++ ). But you are starting to make assumptions about the organization of data in memory. Then you’re really in the hands of the hardware and the compiler, to some extent.

I don’t know if UE is any special case in this respect.

Well it doesn’t really pass Murphy’s Law it seems so I think I will avoid it unless I find out something to the contrary.

Since this thread appeared in my google search, even though OP doesn’t need the answer anymore, here’s what I found in the official UE4 TMap doc:

However, even though TMap doesn’t shuffle elements to fill gaps, pointers to map elements may still be invalidated, as the entire storage can be reallocated when it is full and new elements are added.

So it seems like you can’t really rely on TMap member pointers as a general rule. However if you have the assurance that your map won’t change, or won’t change so much that it’ll need a reallocation, then it seems like you could rely on member pointers.

If you are going to go this route, in my opinion you might as well use a TInlineSetAllocator as the third argument when constructing the map.