The compiler creates the first template for
void go(std::map<int, int>& r)
and second -
void go(const std::map<int, int>& m)
The conversion sequence for the first is an identity transformation: nothing needs to be done, the lvalue argument is bound directly to the link.
The conversion sequence for the second is a qualifier conversion: the lvalue argument needs a constant added to bind to the link.
So the first is the best match. If the variable in main was const, the second would be better, as you can see here , because then the two templates create the same thing, and only then the concept of "more specialized" comes into play.
source share