[over.match.funcs.general]

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

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

### 12.2.2 Candidate functions and argument lists [[over.match.funcs]](over.match.funcs#general)

#### 12.2.2.1 General [over.match.funcs.general]

[1](#1)

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

The subclauses of [[over.match.funcs]](over.match.funcs "12.2.2 Candidate functions and argument lists") describe
the set of candidate functions and the argument list submitted to
overload resolution in each context in which
overload resolution is used[.](#1.sentence-1)

The source transformations and constructions defined
in these subclauses are only for the purpose of describing the
overload resolution process[.](#1.sentence-2)

An implementation is not required
to use such transformations and constructions[.](#1.sentence-3)

[2](#2)

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

The set of candidate functions can contain both member and non-member
functions to be resolved against the same argument list[.](#2.sentence-1)

If a member function is

- [(2.1)](#2.1)

an implicit object member function that is not a constructor, or

- [(2.2)](#2.2)

a static member function and
the argument list includes an implied object argument,

it is considered to have an extra first parameter,
called the [*implicit object parameter*](#def:object_parameter,implicit "12.2.2.1 General [over.match.funcs.general]"),
which represents the object for which the member function has been called[.](#2.sentence-2)

[3](#3)

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

Similarly, when appropriate, the context can construct an
argument list that contains an[*implied object argument*](#def:implied_object_argument "12.2.2.1 General [over.match.funcs.general]") as the first argument in the list to denote
the object to be operated on[.](#3.sentence-1)

[4](#4)

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

For implicit object member functions, the type of the implicit object
parameter is

- [(4.1)](#4.1)

âlvalue reference to cv Xâ for functions declared
without a [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]") or with the& [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]")

- [(4.2)](#4.2)

ârvalue reference to cv Xâ for functions declared with the&& [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]")

whereX is the class of which the function is a direct member andcv is the cv-qualification on the
member function declaration[.](#4.sentence-1)

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

For aconst member
function of classX,
the extra parameter is assumed to have type
âlvalue reference toconst Xâ[.](#4.sentence-2)

â *end example*]

For conversion functions that are implicit object member functions,
the function is considered to be a member of the
class of the implied object argument for the purpose of defining the
type of the implicit object parameter[.](#4.sentence-3)

For non-conversion functions that are implicit object member functions
nominated by a [*using-declaration*](namespace.udecl#nt:using-declaration "9.10 The using declaration [namespace.udecl]") in a derived class, the function is
considered to be a member of the derived class for the purpose of defining
the type of the implicit object parameter[.](#4.sentence-4)

For static member functions, the implicit object parameter is considered
to match any object (since if the function is selected, the object is
discarded)[.](#4.sentence-5)

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

No actual type is established for the implicit object parameter
of a static member function, and no attempt will be made to determine a
conversion sequence for that parameter ([[over.match.best]](over.match.best "12.2.4 Best viable function"))[.](#4.sentence-6)

â *end note*]

[5](#5)

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

During overload resolution, the implied object argument is
indistinguishable from other arguments[.](#5.sentence-1)

The implicit object
parameter, however, retains its identity since
no user-defined conversions can be applied to achieve a type
match with it[.](#5.sentence-2)

For implicit object member functions declared without a [*ref-qualifier*](dcl.decl.general#nt:ref-qualifier "9.3.1 General [dcl.decl.general]"),
even if the implicit object parameter is not const-qualified,
an rvalue can be bound to the parameter
as long as in all other respects the argument can be
converted to the type of the implicit object parameter[.](#5.sentence-3)

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

The fact that such an argument is an rvalue does not
affect the [ranking](over.ics.rank "12.2.4.3 Ranking implicit conversion sequences [over.ics.rank]") of implicit conversion sequences[.](#5.sentence-4)

â *end note*]

[6](#6)

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

Because other than in list-initialization only one user-defined conversion
is allowed
in an
implicit conversion sequence, special rules apply when selecting
the best user-defined conversion ([[over.match.best]](over.match.best "12.2.4 Best viable function"), [[over.best.ics]](over.best.ics "12.2.4.2 Implicit conversion sequences"))[.](#6.sentence-1)

[*Example [2](#example-2)*: class T {public: T();};

class C : T {public: C(int);};
T a = 1; // error: no viable conversion (T(C(1)) not considered) â *end example*]

[7](#7)

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

In each case where conversion functions of a class S are considered
for initializing an object or reference of type T,
the candidate functions include the result of a search
for the [*conversion-function-id*](class.conv.fct#nt:conversion-function-id "11.4.8.3 Conversion functions [class.conv.fct]") operator T in S[.](#7.sentence-1)

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

This search can find a specialization of
a conversion function template ([[basic.lookup]](basic.lookup "6.5 Name lookup"))[.](#7.sentence-2)

â *end note*]

Each such case also defines sets of [*permissible types*](#def:types,permissible "12.2.2.1 General [over.match.funcs.general]") for explicit and non-explicit conversion functions;
each (non-template) conversion function
that

- [(7.1)](#7.1)

is a non-hidden member of S,

- [(7.2)](#7.2)

yields a permissible type, and,

- [(7.3)](#7.3)

for the former set, is non-explicit

is also a candidate function[.](#7.sentence-3)

If initializing an object, for any permissible type cv U, any*cv2* U, *cv2* U&, or *cv2* U&& is also a permissible type[.](#7.sentence-4)

If the set of permissible types for explicit conversion functions is empty,
any candidates that are explicit are discarded[.](#7.sentence-5)

[8](#8)

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

In each case where a candidate is a function template, candidate
function template specializations
are generated using template argument deduction ([[temp.over]](temp.over "13.10.4 Overload resolution"), [[temp.deduct]](temp.deduct "13.10.3 Template argument deduction"))[.](#8.sentence-1)

If a constructor template or conversion function template
has an [*explicit-specifier*](dcl.fct.spec#nt:explicit-specifier "9.2.3 Function specifiers [dcl.fct.spec]") whose [*constant-expression*](expr.const#nt:constant-expression "7.7 Constant expressions [expr.const]") is value-dependent ([[temp.dep]](temp.dep "13.8.3 Dependent names")),
template argument deduction is performed first and then,
if the context admits only candidates that
are not explicit and the generated specialization is explicit ([[dcl.fct.spec]](dcl.fct.spec "9.2.3 Function specifiers")),
it will be removed from the candidate set[.](#8.sentence-2)

Those candidates are then handled as candidate
functions in the usual way[.](#8.sentence-3)[99](#footnote-99 "The process of argument deduction fully determines the parameter types of the function template specializations, i.e., the parameters of function template specializations contain no template parameter types. Therefore, except where specified otherwise, function template specializations and non-template functions ([dcl.fct]) are treated equivalently for the remainder of overload resolution.")

A given name can refer to, or a conversion can consider,
one or more function templates as well as a set of non-template functions[.](#8.sentence-4)

In such a case, the
candidate functions generated from each function template are combined
with the set of non-template candidate functions[.](#8.sentence-5)

[9](#9)

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

A
defaulted move special member function ([[class.copy.ctor]](class.copy.ctor "11.4.5.3 Copy/move constructors"), [[class.copy.assign]](class.copy.assign "11.4.6 Copy/move assignment operator"))
that is defined as deleted
is excluded from the set of candidate functions in all contexts[.](#9.sentence-1)

A constructor inherited from class type C ([[class.inhctor.init]](class.inhctor.init "11.9.4 Initialization by inherited constructor"))
that has a first parameter of type âreference to *cv1* Pâ
(including such a constructor instantiated from a template)
is excluded from the set of candidate functions
when constructing an object of type *cv2* D if the argument list has exactly one argument andC is reference-related to P andP is reference-related to D[.](#9.sentence-2)

[*Example [3](#example-3)*: struct A { A(); // #1 A(A &&); // #2template<typename T> A(T &&); // #3};struct B : A {using A::A;
 B(const B &); // #4 B(B &&) = default; // #5, implicitly deletedstruct X { X(X &&) = delete; } x;};extern B b1;
B b2 = static_cast<B&&>(b1); // calls #4: #1 is not viable, #2, #3, and #5 are not candidatesstruct C { operator B&&(); };
B b3 = C(); // calls #4 â *end example*]

[99)](#footnote-99)[99)](#footnoteref-99)

The process of argument deduction fully
determines the parameter types of
the
function template specializations,
i.e., the parameters of
function template specializations
contain
no template parameter types[.](#footnote-99.sentence-1)

Therefore, except where specified otherwise,
function template specializations
and non-template functions ([[dcl.fct]](dcl.fct "9.3.4.6 Functions")) are treated equivalently
for the remainder of overload resolution[.](#footnote-99.sentence-2)
