[over.best.ics.general]

# 12 Overloading [[over]](./#over)

## 12.2 Overload resolution [[over.match]](over.match#over.best.ics.general)

### 12.2.4 Best viable function [[over.match.best]](over.match.best#over.best.ics.general)

#### 12.2.4.2 Implicit conversion sequences [[over.best.ics]](over.best.ics#general)

#### 12.2.4.2.1 General [over.best.ics.general]

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2095)

An [*implicit conversion sequence*](#def:conversion_sequence,implicit "12.2.4.2.1 General [over.best.ics.general]") is a sequence of conversions used
to convert an argument in a function call to the type of the
corresponding parameter of the function being called[.](#1.sentence-1)

The
sequence of conversions is an implicit conversion as defined in[[conv]](conv "7.3 Standard conversions"), which means it is governed by the rules for
initialization of an object or reference by a single
expression ([[dcl.init]](dcl.init "9.5 Initializers"), [[dcl.init.ref]](dcl.init.ref "9.5.4 References"))[.](#1.sentence-2)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2106)

Implicit conversion sequences are concerned only with the type,
cv-qualification, and value category of the argument and how these
are converted to match the corresponding properties of the
parameter[.](#2.sentence-1)

[*Note [1](#note-1)*:

Other properties, such as the lifetime, storage duration, linkage,
alignment, accessibility of the argument, whether the argument is a bit-field,
and whether a function is [deleted](dcl.fct.def.delete "9.6.3 Deleted definitions [dcl.fct.def.delete]"), are ignored[.](#2.sentence-2)

So, although an implicit
conversion sequence can be defined for a given argument-parameter
pair, the conversion from the argument to the parameter might still
be ill-formed in the final analysis[.](#2.sentence-3)

â *end note*]

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2121)

A
well-formed implicit conversion
sequence is one of the following forms:

- [(3.1)](#3.1)

a [standard conversion sequence](over.ics.scs "12.2.4.2.2 Standard conversion sequences [over.ics.scs]"),

- [(3.2)](#3.2)

a [user-defined conversion sequence](over.ics.user "12.2.4.2.3 User-defined conversion sequences [over.ics.user]"), or

- [(3.3)](#3.3)

an [ellipsis conversion sequence](over.ics.ellipsis "12.2.4.2.4 Ellipsis conversion sequences [over.ics.ellipsis]")[.](#3.sentence-1)

[4](#4)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2134)

However, if the target is

- [(4.1)](#4.1)

the first parameter of a constructor or

- [(4.2)](#4.2)

the object parameter of a user-defined conversion function

and the constructor or user-defined conversion function is a candidate by

- [(4.3)](#4.3)

[[over.match.ctor]](over.match.ctor "12.2.2.4 Initialization by constructor"), when the argument is the temporary in the second
step of a class copy-initialization,

- [(4.4)](#4.4)

[[over.match.copy]](over.match.copy "12.2.2.5 Copy-initialization of class by user-defined conversion"), [[over.match.conv]](over.match.conv "12.2.2.6 Initialization by conversion function"), or [[over.match.ref]](over.match.ref "12.2.2.7 Initialization by conversion function for direct reference binding") (in all cases), or

- [(4.5)](#4.5)

the second phase of [[over.match.list]](over.match.list "12.2.2.8 Initialization by list-initialization") when the initializer list has exactly one element that
is itself an initializer list, and
the target is the first parameter of a constructor of class X, and
the conversion is to X or reference to cv X,

user-defined conversion sequences are not considered[.](#4.sentence-1)

[*Note [2](#note-2)*:

These rules prevent more than one user-defined conversion from being
applied during overload resolution, thereby avoiding infinite recursion[.](#4.sentence-2)

â *end note*]

[*Example [1](#example-1)*: struct Y { Y(int); };struct A { operator int(); };
Y y1 = A(); // error: A​::​operator int() is not a candidatestruct X { X(); };struct B { operator X(); };
B b;
X x{{b}}; // error: B​::​operator X() is not a candidate â *end example*]

[5](#5)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2170)

For the case where the parameter type is a reference, see [[over.ics.ref]](over.ics.ref "12.2.4.2.5 Reference binding")[.](#5.sentence-1)

[6](#6)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2173)

When the parameter type is not a reference, the implicit conversion
sequence models a copy-initialization of the parameter from the argument
expression[.](#6.sentence-1)

The implicit conversion sequence is the one required to convert the
argument expression to a prvalue of the type of
the parameter[.](#6.sentence-2)

[*Note [3](#note-3)*:

When the parameter has a class type, this is a conceptual conversion
defined for the purposes of [[over]](over "12 Overloading"); the actual initialization is
defined in terms of constructors and is not a conversion[.](#6.sentence-3)

â *end note*]

[7](#7)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2186)

When the cv-unqualified version of the type of the argument expression
is the same as the parameter type,
the implicit conversion sequence is an identity conversion[.](#7.sentence-1)

When the parameter has a class type and the argument expression has a
(possibly cv-qualified)
derived class type, the implicit conversion sequence is a
derived-to-baseconversion from the derived class to the base class[.](#7.sentence-2)

A derived-to-base conversion has Conversion rank ([[over.ics.scs]](over.ics.scs "12.2.4.2.2 Standard conversion sequences"))[.](#7.sentence-3)

[*Note [4](#note-4)*:

There is no such standard conversion; this derived-to-base conversion exists
only in the description of implicit conversion sequences[.](#7.sentence-4)

â *end note*]

[*Example [2](#example-2)*:

An implicit conversion sequence from an argument of type const A to a parameter of type A can be formed,
even if overload resolution for copy-initialization of A from the argument would not find a viable function ([[over.match.ctor]](over.match.ctor "12.2.2.4 Initialization by constructor"), [[over.match.viable]](over.match.viable "12.2.3 Viable functions"))[.](#7.sentence-5)

The implicit conversion sequence for that case is the identity sequence; it
contains no âconversionâ from const A to A[.](#7.sentence-6)

â *end example*]

[8](#8)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2210)

When the parameter is the implicit object parameter of a static member function,
the implicit conversion sequence is a standard conversion sequence
that is neither better nor worse than any other standard conversion sequence[.](#8.sentence-1)

[9](#9)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2215)

In all contexts, when converting to the implicit object parameter
or when converting to the left operand of an assignment operation
only standard conversion sequences are allowed[.](#9.sentence-1)

[*Note [5](#note-5)*:

When a conversion to the explicit object parameter occurs,
it can include user-defined conversion sequences[.](#9.sentence-2)

â *end note*]

[10](#10)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2224)

If no conversions are required to match an argument to a
parameter type, the implicit conversion sequence is the standard
conversion sequence consisting of the identity conversion ([[over.ics.scs]](over.ics.scs "12.2.4.2.2 Standard conversion sequences"))[.](#10.sentence-1)

[11](#11)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2229)

If no sequence of conversions can be found to convert an argument
to a parameter type, an implicit conversion sequence cannot be formed[.](#11.sentence-1)

[12](#12)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2233)

If there are multiple well-formed implicit conversion sequences
converting the argument to the parameter type, the implicit
conversion sequence associated with the parameter is defined to be
the unique conversion sequence designated the[*ambiguous conversion sequence*](#def:conversion_sequence,ambiguous "12.2.4.2.1 General [over.best.ics.general]")[.](#12.sentence-1)

For the purpose of ranking implicit conversion sequences as described
in [[over.ics.rank]](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences"), the ambiguous conversion sequence is treated
as a user-defined conversion sequence that is indistinguishable from any
other user-defined conversion sequence[.](#12.sentence-2)

[*Note [6](#note-6)*:

This rule prevents a function from becoming non-viable because of an ambiguous
conversion sequence for one of its parameters[.](#12.sentence-3)

[*Example [3](#example-3)*: class B;class A { A (B&);};class B { operator A (); };class C { C (B&); };void f(A) { }void f(C) { } B b;
f(b); // error: ambiguous because there is a conversion b â C (via constructor)// and an (ambiguous) conversion b â A (via constructor or conversion function)void f(B) { } f(b); // OK, unambiguous â *end example*]

â *end note*]

If a function that uses the ambiguous conversion sequence is selected
as the best viable function, the call will be ill-formed because the conversion
of one of the arguments in the call is ambiguous[.](#12.sentence-4)

[13](#13)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/overloading.tex#L2266)

The three forms of implicit conversion sequences mentioned above
are defined in the following subclauses[.](#13.sentence-1)
