### Argument Matching in Overloaded Functions

When an overloaded function or overloaded operator is called, the compiler chooses the function declaration with the best match on all arguments from all the function declarations that are visible. The compiler compares the actual arguments of a function call with the formal arguments of all declarations of the function that are visible. For a best match to occur, the compiler must be able to distinguish a function that:

- Has at least as good a match on all arguments as any other function with the same name
- Has at least one better argument match than any other function with the same name

If no such function exists, the call is not allowed. A call to an overloaded function has three possible outcomes. The compiler can find:

- An exact match
- No match
- An ambiguous match

An ambiguous match occurs when the actual arguments of the function call match more than one overloaded function.

Argument matching can include performing standard and user-defined conversions on the arguments to match the actual arguments with the formal arguments. Only a single user-defined conversion is performed in a sequence of conversions on an actual argument. In addition, the best-matching sequence of standard conversions is performed on an actual argument. The best-matching sequence is the shortest sequence of conversions between two standard types. For example , the conversion:

    int -> float -> double

can be shortened to the best-matching conversion sequence:

    int -> double

because the conversion from int to double is allowed.

Trivial Conversions do not affect the choice of conversion sequence.

Sequence of Argument Conversions
Trivial Conversions

Overloading Functions
Overloading Operators