This is not correct. The first and third functions have differing signatures, namely sum(int,int) and sum(int&,int&). See, for instance, the following program demonstrating how to call foo(int,int) without ambiguity:
The reason this works is because foo(int&,int&) cannot discard const...