I read Map for STL does not allow to overwrite value of existing key by emplace() or insert()
However, it LOOKS like Emplace() of UE4 TMap allows to overwrite when existing key with different value is applied.
Am I understanding correctly, or overwriting should not be happened in TMap, too?
Keep in mind that Unreal Engine's TMap
is not equivalent to C++'s map
. You've already figured it out, but the Emplace
method in the TMap
class does differ from C++'s emplace
method in the map
class in that calling Emplace
with a key that already exists in the map will replace the original value associated with that key.
For the TMap
class, the purpose of the Emplace
method is to avoid creating copies of non primitive types for the key and value to be inserted into the map. Note that Emplace
only works on keys and values of an object type that has a single argument constructor. Otherwise, the Emplace
method behaves similarly to the Add
method.