Implicit conversion sequences (C++ only)

An implicit conversion sequence is the sequence of conversions required to convert an argument in a function call to the type of the corresponding parameter in a function declaration.

The compiler will try to determine an implicit conversion sequence for each argument. It will then categorize each implicit conversion sequence in one of three categories and rank them depending on the category. The compiler will not allow any program in which it cannot find an implicit conversion sequence for an argument.

The following are the three categories of conversion sequences in order from best to worst:

Note:

Two standard conversion sequences or two user-defined conversion sequences may have different ranks.

Standard conversion sequences

Standard conversion sequences are categorized in one of three ranks. The ranks are listed in order from best to worst:

The compiler ranks a standard conversion sequence by its worst-ranked standard conversion. For example, if a standard conversion sequence has a floating-point conversion, then that sequence has conversion rank.

Related information

User-defined conversion sequences

A user-defined conversion sequence consists of the following:

A user-defined conversion sequence A is better than a user-defined conversion sequence B if the both have the same user-defined conversion function or constructor, and the second standard conversion sequence of A is better than the second standard conversion sequence of B.

Ellipsis conversion sequences

An ellipsis conversion sequence occurs when the compiler matches an argument in a function call with a corresponding ellipsis parameter.