As already mentioned, the rules are fully described in the standard. As a basic rule, the compiler will choose an overload that requires the least automatic transformations, with the caveat that it will never apply 2 custom transforms.
Integer types are automatically thrown around. Therefore, if you have a function overloaded with int and double , the compiler will select the int function if called with a constant, which is an integer. If you did not have an int version, the compiler will select double . And among the various integer types, the compiler prefers int for integer constants, because that is their type. If you are overloaded with short and unsigned short , but called with constant 5 , the compiler will complain that it cannot determine which overload to use.
Scott Meyers' book does have the best explanation I've ever read.
source share