diff --git a/source/expressions.tex b/source/expressions.tex index 9a14de3699..a609acd891 100644 --- a/source/expressions.tex +++ b/source/expressions.tex @@ -675,12 +675,6 @@ function.\footnote{This conversion never applies to non-static member functions because an lvalue that refers to a non-static member function cannot be obtained.} -\pnum -\begin{note} -See~\ref{over.over} for additional rules for the case where the function -is overloaded. -\end{note} - \rSec2[conv.rval]{Temporary materialization conversion} \indextext{conversion!temporary materialization}% @@ -1316,12 +1310,14 @@ \end{note} \pnum -A program that refers -explicitly or implicitly -to a function with a trailing \grammarterm{requires-clause} +For an \grammarterm{id-expression} that denotes an overload set, +overload resolution is performed +to select a unique function~(\ref{over.match}, \ref{over.over}). +\begin{note} +A program cannot refer to a function +with a trailing \grammarterm{requires-clause} whose \grammarterm{constraint-expression} is not satisfied, -other than to declare it, -is ill-formed. +because such functions are never selected by overload resolution. \begin{example} \begin{codeblock} template struct A { @@ -1340,6 +1336,7 @@ even though \tcode{f} is an unevaluated operand\iref{expr.prop}. \end{example} +\end{note} \rSec3[expr.prim.id.unqual]{Unqualified names} @@ -2903,7 +2900,13 @@ A function call is a postfix expression followed by parentheses containing a possibly empty, comma-separated list of \grammarterm{initializer-clause}{s} which -constitute the arguments to the function. The postfix expression shall +constitute the arguments to the function. +\begin{note} +If the postfix expression is a function or member function name, +the appropriate function and the validity of the call +are determined according to the rules in~\ref{over.match}. +\end{note} +The postfix expression shall have function type or function pointer type. For a call to a non-member function or to a static member function, the postfix expression shall either be an lvalue that refers to a @@ -2927,9 +2930,7 @@ \end{note} \pnum -If a function or member function name is used, -the appropriate function and the validity of the call are determined -according to the rules in~\ref{over.match}. If the selected +If the selected function is non-virtual, or if the \grammarterm{id-expression} in the class member access expression is a \grammarterm{qualified-id}, that function is called. Otherwise, its final overrider\iref{class.virtual} in the dynamic type @@ -4246,10 +4247,10 @@ \pnum \indextext{overloaded function!address of}% +\begin{note} The address of an overloaded function\iref{over} can be taken only in a context that uniquely determines which version of the overloaded function is referred to (see~\ref{over.over}). -\begin{note} Since the context might determine whether the operand is a static or non-static member function, the context can also affect whether the expression has type ``pointer to function'' or ``pointer to member diff --git a/source/overloading.tex b/source/overloading.tex index 92ab51a823..4779c151d1 100644 --- a/source/overloading.tex +++ b/source/overloading.tex @@ -3141,19 +3141,12 @@ \indextext{overloaded function!address of} \pnum -A use of an overloaded function name without arguments is resolved -in certain contexts to a function, a pointer to function or a pointer to -member function for a specific function from the overload set. -A function template name is considered to name a set of overloaded functions -in such contexts. -A function with type \tcode{F} is selected for the function type \tcode{FT} -of the target type required in the context if \tcode{F} -(after possibly applying the function pointer conversion\iref{conv.fctptr}) -is identical to \tcode{FT}. -\begin{note} -That is, the class of which the function is a member is ignored when matching a -pointer-to-member-function type. -\end{note} +A use of a function name without arguments is resolved to +a function, a pointer to function, or a pointer to member function +for a specific function +that is chosen from a set of selected functions +determined based on the target type required in the context (if any), +as described below. The target can be \begin{itemize} \item @@ -3174,25 +3167,33 @@ a non-type \grammarterm{template-parameter}\iref{temp.arg.nontype}. \end{itemize} - -The overloaded function name can be preceded by the -\tcode{\&} -operator. -An overloaded function name shall not be used without arguments in contexts -other than those listed. +The function name can be preceded by the \tcode{\&} operator. \begin{note} -Any redundant set of parentheses surrounding the overloaded function name is +Any redundant set of parentheses surrounding the function name is ignored\iref{expr.prim.paren}. \end{note} \pnum -If the name is a function template, template argument deduction is -done\iref{temp.deduct.funcaddr}, and if the argument deduction succeeds, +If there is no target, all non-template functions named are selected. +Otherwise, a non-template function with type \tcode{F} +is selected for the function type \tcode{FT} of the target type +if \tcode{F} +(after possibly applying the function pointer conversion\iref{conv.fctptr}) +is identical to \tcode{FT}. +\begin{note} +That is, the class of which the function is a member is ignored when matching a +pointer-to-member-function type. +\end{note} + +\pnum +For each function template designated by the name, +template argument deduction is done\iref{temp.deduct.funcaddr}, and +if the argument deduction succeeds, the resulting template argument list is used to generate a single function template specialization, -which is added to the set of overloaded functions +which is added to the set of selected functions considered. \begin{note} As described in~\ref{temp.arg.explicit}, if deduction fails and the @@ -3212,6 +3213,7 @@ reference to function type. Non-static member functions match targets of pointer-to-member-function type. +%% FIXME: Should this only apply after the eliminations in the next paragraph? If a non-static member function is selected, the reference to the overloaded function name is required to have the form of a pointer to member as described in~\ref{expr.unary.op}. diff --git a/source/templates.tex b/source/templates.tex index 09c535c776..474138e41c 100644 --- a/source/templates.tex +++ b/source/templates.tex @@ -7802,13 +7802,15 @@ \pnum Template arguments can be deduced from the type specified when taking the address of an overloaded function\iref{over.over}. -The function template's function type and the specified type +If there is a target, +the function template's function type and the target type are used as the types of \tcode{P} and \tcode{A}, and the deduction is done as described in~\ref{temp.deduct.type}. +Otherwise, deduction is performed with empty sets of types P and A. \pnum A placeholder type\iref{dcl.spec.auto} in the return type of a