The next call before going into the second Insert method is
pair(pair<_Other1, _Other2>&& _Right)
. This happens irrespective of whether the second Insert takes an&&
or aconst &
. What's going on here?
That is std::pair
's converting constructor: it's converting the pair that you pass - std::make_pair(key, value)
- from std::pair<Key, Value>
to the second Insert
functions's parameter type std::pair<const Key, Value>
. You could avoid the conversion if you specify the pair type yourself instead of having std::make_pair
deduce it:
Insert(std::pair<const Key, Value>{key, value});
Of course, this is copying the parameters into a pair
, and in C++11 we have the rule of thumb that if you are going to copy something you should accept it by value. So maybe implement this Insert
as:
template <typename Key, typename Value, typename HashFunction, typename Equals>
void FastHash<Key, Value, HashFunction, Equals>::Insert(Key key, Value value)
{
Insert(std::pair<const Key, Value>{std::move(key), std::move(value)});
}