diff --git a/source/classes.tex b/source/classes.tex index 52d5b5baba..fcabddde7d 100644 --- a/source/classes.tex +++ b/source/classes.tex @@ -944,9 +944,10 @@ a member thereof, as described below. \pnum -When an \grammarterm{id-expression}\iref{expr.prim.id} that is not part of a -class member access syntax\iref{expr.ref} and not used to form a -pointer to member\iref{expr.unary.op} is used +When an \grammarterm{id-expression}\iref{expr.prim.id} that is +neither part of a class member access syntax\iref{expr.ref} +nor the unparenthesized operand of +the unary \tcode{\&} operator\iref{expr.unary.op} is used where the current class is \tcode{X}\iref{expr.prim.this}, if name lookup\iref{basic.lookup} resolves the name in the diff --git a/source/expressions.tex b/source/expressions.tex index 24ca008a05..88fe44dd14 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -1341,7 +1341,7 @@ \pnum An \grammarterm{id-expression} that denotes a non-static data member or -non-static member function of a class can only be used: +implicit object member function of a class can only be used: \begin{itemize} \item as part of a class member access\iref{expr.ref} in which the object expression @@ -3171,21 +3171,6 @@ conversion\iref{conv.func} is suppressed on the postfix expression), or have function pointer type. -\pnum -For a call to a non-static member function, -the postfix expression shall be an -implicit\iref{class.mfct.non.static,class.static} or explicit -class member access\iref{expr.ref} whose \grammarterm{id-expression} is a -function member name, or a pointer-to-member -expression\iref{expr.mptr.oper} selecting a function member; the call is as a member of -the class object referred to by the -object expression. In the case of an implicit class -member access, the implied object is the one pointed to by \keyword{this}. -\begin{note} -A member function call of the form \tcode{f()} is interpreted as -\tcode{(*\keyword{this}).f()} (see~\ref{class.mfct.non.static}). -\end{note} - \pnum If the selected function is non-virtual, or if the \grammarterm{id-expression} in the class diff --git a/source/overloading.tex b/source/overloading.tex index 0d61a81420..b9f47ea50b 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -154,15 +154,17 @@ \indextext{function!overload resolution and}% The set of candidate functions can contain both member and non-member functions to be resolved against the same argument list. -So that argument and parameter lists are comparable within this -heterogeneous set, a member function that does not have an explicit object parameter is considered to have an -extra first parameter, called the -\defn{implicit object parameter}, -which represents the object for which the member function has been -called. -For the purposes of overload resolution, both static and -non-static member functions have an object parameter, -but constructors do not. +If a member function is +\begin{itemize} +\item +an implicit object member function that is not a constructor, or +\item +a static member function and +the argument list includes an implied object argument, +\end{itemize} +it is considered to have an extra first parameter, +called the \defnadj{implicit}{object parameter}, +which represents the object for which the member function has been called. \pnum Similarly, when appropriate, the context can construct an @@ -367,7 +369,11 @@ \pnum If the \grammarterm{postfix-expression} is the address of an overload set, overload resolution is applied using that set as described above. -If the function selected by overload resolution is a non-static member function, +\begin{note} +No implied object argument is added in this case. +\end{note} +If the function selected by overload resolution is +an implicit object member function, the program is ill-formed. \begin{note} The resolution of the address of an @@ -443,15 +449,16 @@ The function declarations found by name lookup\iref{basic.lookup} constitute the set of candidate functions. Because of the rules for name lookup, the set of candidate functions -consists (1) entirely of non-member functions or (2) entirely of +consists either entirely of non-member functions or entirely of member functions of some class \tcode{T}. -In case (1), +In the former case or +if the \grammarterm{primary-expression} is the address of an overload set, the argument list is the same as the \grammarterm{expression-list} in the call. -In case (2), the argument list is the +Otherwise, the argument list is the \grammarterm{expression-list} in the call augmented by the addition of an implied object argument as in a qualified function call. @@ -485,6 +492,19 @@ a(); // OK, \tcode{(*this).a()} } +void c(this const C&); // \#1 +void c()&; // \#2 +static void c(int = 0); // \#3 + +void d() { + c(); // error: ambiguous between \#2 and \#3 + (C::c)(); // error: as above + (&(C::c))(); // error: cannot resolve address of overloaded \tcode{this->C::c}\iref{over.over} + (&C::c)(C{}); // selects \#1 + (&C::c)(*this); // error: selects \#2, and is ill-formed\iref{over.match.call.general} + (&C::c)(); // selects \#3 +} + void f(this const C&); void g() const { f(); // OK, \tcode{(*this).f()}