[over.call.func]

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

## 12.2 Overload resolution [[over.match]](over.match#over.call.func)

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

#### 12.2.2.2 Function call syntax [[over.match.call]](over.match.call#over.call.func)

#### 12.2.2.2.2 Call to designated function [over.call.func]

[1](#1)

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

Of interest in [over.call.func] are only those function calls
in which the [*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") ultimately contains
an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") that designates one or more functions[.](#1.sentence-1)

Such a[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]"),
perhaps nested arbitrarily deep in
parentheses, has one of the following forms:

[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]"):  
[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") . [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]")  
[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") . [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")  
[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") -> [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]")  
[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") -> [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")  
[*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]")  
[*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")

These represent two syntactic subcategories of function calls:
qualified function calls and unqualified function calls[.](#1.sentence-3)

[2](#2)

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

In qualified function calls,
the function is designated by
an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") E preceded by an -> or . operator[.](#2.sentence-1)

Since the
constructA->B is generally equivalent to(*A).B,
the rest of[[over]](over "12 Overloading") assumes, without loss of generality, that all member
function calls have been normalized to the form that uses an
object and the. operator[.](#2.sentence-2)

Furthermore, [[over]](over "12 Overloading") assumes that
the[*postfix-expression*](expr.post.general#nt:postfix-expression "7.6.1.1 General [expr.post.general]") that is the left operand of the. operator
has type âcv Tâ
whereT denotes a class[.](#2.sentence-3)[100](#footnote-100 "Note that cv-qualifiers on the type of objects are significant in overload resolution for both glvalue and class prvalue objects.")

The set of candidate functions either
is the set found by name lookup ([[class.member.lookup]](class.member.lookup "6.5.2 Member name lookup"))
if E is an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or
is the set determined as specified in [[expr.prim.splice]](expr.prim.splice "7.5.9 Expression splicing") if E is a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")[.](#2.sentence-4)

The argument list is the[*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") in the call augmented by the addition of the left operand of
the. operator in the normalized member function call as the
implied object argument ([[over.match.funcs]](over.match.funcs "12.2.2 Candidate functions and argument lists"))[.](#2.sentence-5)

[3](#3)

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

In unqualified function calls, the function is designated by
an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") E[.](#3.sentence-1)

The set of candidate functions either
is the set found by name lookup ([[basic.lookup]](basic.lookup "6.5 Name lookup"))
if E is an [*id-expression*](expr.prim.id.general#nt:id-expression "7.5.5.1 General [expr.prim.id.general]") or
is the set determined as specified in [[expr.prim.splice]](expr.prim.splice "7.5.9 Expression splicing") if E is a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]")[.](#3.sentence-2)

The set of candidate functions
consists either entirely of non-member functions or entirely of
member functions of some classT[.](#3.sentence-3)

In the former case or
if E is either a [*splice-expression*](expr.prim.splice#nt:splice-expression "7.5.9 Expression splicing [expr.prim.splice]") or
the address of an overload set,
the argument list is
the same as the[*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") in the call[.](#3.sentence-4)

Otherwise, the argument list is the[*expression-list*](expr.post.general#nt:expression-list "7.6.1.1 General [expr.post.general]") in the call augmented by the addition of an implied object
argument as in a qualified function call[.](#3.sentence-5)

If the current class is, or is derived from, T, and the keywordthis ([[expr.prim.this]](expr.prim.this "7.5.3 This")) refers to it,

- [(3.1)](#3.1)

if the unqualified function call
appears in a precondition assertion of a constructor
or a postcondition assertion of a destructor
and overload resolution selects a non-static member function,
the call is ill-formed;

- [(3.2)](#3.2)

otherwise,
the implied object argument is(*this)[.](#3.sentence-6)

Otherwise,

- [(3.3)](#3.3)

if overload resolution selects a non-static member function,
the call is ill-formed;

- [(3.4)](#3.4)

otherwise,
a contrived object of typeT becomes the implied object argument[.](#3.sentence-7)[101](#footnote-101 "An implied object argument is contrived to correspond to the implicit object parameter attributed to member functions during overload resolution. It is not used in the call to the selected function. Since the member functions all have the same implicit object parameter, the contrived object will not be the cause to select or reject a function.")

[*Example [1](#example-1)*: struct C {bool a(); void b() { a(); // OK, (*this).a()}void c(this const C&); // #1void c() &; // #2static void c(int = 0); // #3void d() { c(); // error: ambiguous between #2 and #3(C::c)(); // error: as above(&(C::c))(); // error: cannot resolve address of overloaded this->C​::​c ([[over.over]](over.over "12.3 Address of an overload set"))(&C::c)(C{}); // selects #1(&C::c)(*this); // error: selects #2, and is ill-formed ([[over.match.call.general]](over.match.call.general "12.2.2.2.1 General"))(&C::c)(); // selects #3}void f(this const C&); void g() const { f(); // OK, (*this).f() f(*this); // error: no viable candidate for (*this).f(*this)this->f(); // OK}static void h() { f(); // error: contrived object argument, but overload resolution// picked a non-static member function f(C{}); // error: no viable candidate C{}.f(); // OK}void k(this int); operator int() const; void m(this const C& c) { c.k(); // OK} C() pre(a()) // error: implied this in constructor precondition pre(this->a()) // OK post(a()); // OK~C() pre(a()) // OK post(a()) // error: implied this in destructor postcondition post(this->a()); // OK}; â *end example*]

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

Note that cv-qualifiers on the type of objects are
significant in overload
resolution for
both glvalue and class prvalue objects[.](#footnote-100.sentence-1)

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

An implied object argument is contrived to
correspond to the implicit object
parameter attributed to member functions during overload resolution[.](#footnote-101.sentence-1)

It is not
used in
the call to the selected function[.](#footnote-101.sentence-2)

Since the member functions all have the
same implicit
object parameter, the contrived object will not be the cause to select or
reject a
function[.](#footnote-101.sentence-3)
