Usually, the key is used only for comparison purposes, so you may wonder why rvalue semantics are needed: a reference to const should already cover this case.
But it is worth noting that the operator [] can indeed create a new key / value pair: if the key did not exist on the map yet.
In this case, if the second overload was used, the card can safely move the provided key value on the card (when initializing the default value). In my opinion, this is a rather rare and insignificant optimization, but when you are a standard C ++ library, you should not make any efforts to save someone else's cycle, even if this happens only once!
Regarding the second question, I might be wrong, but it should consider the second overload as the best overload.
Edit: There is also a valid point that it can allow you to use motion objects only as key values, even if this is a moot decision
source share