How to remove nullptr as a key from TMap

Hello guys:

I am writing a Threat Map for target selection for battle that has a large number of AI.
Sometimes, here is my Tmap declaration:

TMap ThreatMap;

Like so, I am using the Character ref to find the threat value in the TMap. Sometime, the key = nullptr, and I try to remove it with ThreatMap.Remove(Key), however the Tmap nullptr key element is still there. Anyone know what is going on?

Thanks

http://www.cplusplus.com/doc/tutorial/pointers/
more pointers.

So you need to assert the condition, if its null then move on, write to that spot, not sure what your doing.

First of all, it’s a little odd that you’re using a pointer as a key in an associative array. It’s not wrong necessarily, just strange. I think personally I’d use the name of the character instead of the pointer to it.

Second, how are you using this? You’re not putting nullptr into the TMap yourself, are you? (Don’t.) It’s that you have a character that has been removed from the scene, so its reference is null right? If that’s the case, then it’s likely because the garbage collector doesn’t care about the TMap keys. (But that’s just a guess, I haven’t looked at the TMap code). To test that theory, Try making an additional TArray and put each character in that array as well. The garbage collecter does respect the TArray, so it will prevent the characters from being removed while they’re still in use in the TMap.

Obviously that shouldn’t be your final solution, but it might help you figure out what is happening.

…so C++
its great isn’t it.
NULL POINTER (nullprt) is …well here is some info

if you didn’t have that NULL POINTER you would crash your system (weather soft or hard crash)
so no you can’t remove that. You will need more info on pointers to continue.