Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e28cedb
CWG1953 Data races and common initial sequence
burblebee Nov 27, 2024
97837d7
CWG2283 Missing complete type requirements
burblebee Nov 27, 2024
b6c37b1
CWG2815 Overload resolution for references/pointers to noexcept funct…
burblebee Nov 27, 2024
fc62fb5
CWG2879 Undesired outcomes with const_cast
burblebee Nov 27, 2024
f304952
CWG2890 Defining members of local classes
burblebee Nov 27, 2024
0b1cf18
CWG2894 Functional casts create prvalues of reference type
burblebee Nov 27, 2024
4c2bc49
CWG2899 Bad value representations should cause undefined behavior
burblebee Nov 27, 2024
35569a9
CWG2901 Unclear semantics for near-match aliased access
burblebee Nov 27, 2024
c7193c9
CWG2905 Value-dependence of noexcept-expression
burblebee Nov 28, 2024
538a55b
CWG2906 Lvalue-to-rvalue conversion of class types for conditional op…
burblebee Nov 28, 2024
96cdeff
CWG2907 Constant lvalue-to-rvalue conversion on uninitialized std::nu…
burblebee Nov 28, 2024
de1b557
CWG2908 Counting physical source lines for __LINE__
burblebee Nov 28, 2024
3171600
CWG2909 Subtle difference between constant-initialized and constexpr
burblebee Nov 28, 2024
8b66da2
CWG2910 Effect of requirement-parameter-lists on odr-usability
burblebee Nov 28, 2024
1348564
CWG2911 Unclear meaning of expressions "appearing within" subexpressions
burblebee Nov 28, 2024
3bd5fcb
CWG2913 Grammar for deduction-guide has requires-clause in the wrong …
burblebee Nov 28, 2024
521364d
CWG2915 Explicit object parameters of type void
burblebee Nov 28, 2024
3f3c5c9
CWG2918 Consideration of constraints for address of overloaded function
burblebee Nov 28, 2024
a7eff9a
CWG2919 Conversion function candidates for initialization of const lv…
burblebee Nov 28, 2024
fb49b41
CWG2921 Exporting redeclarations of entities not attached to a named …
burblebee Nov 28, 2024
1811723
CWG2922 constexpr placement-new is too permissive
burblebee Nov 28, 2024
011e687
CWG2924 Undefined behavior during constant evaluation
burblebee Nov 28, 2024
5225f68
[dcl.attr.assume] Add missing \pnum's
tkoeppe Dec 16, 2024
6280657
CWG2927 Unclear status of translation unit with module keyword
burblebee Nov 28, 2024
018efd1
CWG2930 Unclear term "copy/move operation" in specification of copy e…
burblebee Nov 28, 2024
18f8ef2
CWG2931 Restrictions on operator functions that are explicit object m…
burblebee Nov 28, 2024
c0a7e92
CWG2933 Dangling references
burblebee Nov 28, 2024
716c99a
CWG2936 Local classes of templated functions should be part of the cu…
burblebee Nov 28, 2024
8384ae9
CWG2937 Grammar for preprocessing-file has no normative effect
burblebee Nov 28, 2024
afaa669
CWG2939 Do not allow reinterpret_cast from prvalue to rvalue reference
burblebee Nov 28, 2024
8f6236e
CWG2944 Unsequenced throw-expressions
burblebee Nov 28, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
CWG2918 Consideration of constraints for address of overloaded function
  • Loading branch information
burblebee authored and tkoeppe committed Dec 15, 2024
commit 3f3c5c988241b101ac7eb121bf6bdc1d7751c03b
32 changes: 32 additions & 0 deletions source/compatibility.tex
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,38 @@
\end{codeblock}
\end{example}

\diffref{temp.deduct.call}
\change
Template argument deduction from overload sets succeeds in more cases.
\rationale
Allow consideration of constraints to disambiguate overload sets
used as parameters in function calls.
\effect
Valid \CppXXIII{} code may become ill-formed.
\begin{example}
\begin{codeblock}
template <typename T>
void f(T &&, void (*)(T &&));

void g(int &); // \#1
inline namespace A {
void g(short &&); // \#2
}
inline namespace B {
void g(short &&); // \#3
}

void q() {
int x;
f(x, g); // ill-formed; previously well-formed, deducing \tcode{T = int\&}
}
\end{codeblock}
There is no change to the applicable deduction rules for
the individual \tcode{g} candidates:
Type deduction from \#1 does not succeed;
type deductions from \#2 and \#3 both succeed.
\end{example}

\rSec2[diff.cpp23.library]{\ref{library}: library introduction}

\diffref{headers}
Expand Down
42 changes: 24 additions & 18 deletions source/overloading.tex
Original file line number Diff line number Diff line change
Expand Up @@ -1795,19 +1795,8 @@

\item
$\tcode{F}_1$ and $\tcode{F}_2$ are non-template functions and
\begin{itemize}
\item
they have the same non-object-parameter-type-lists\iref{dcl.fct}, and
\item
if they are member functions, both are direct members of the same class, and
\item
if both are non-static member functions,
they have the same types for their object parameters, and
\item
$\tcode{F}_1$ is more constrained than $\tcode{F}_2$
according to the partial ordering of constraints described in
\ref{temp.constr.order}
\end{itemize}
$\tcode{F}_1$ is more partial-ordering-constrained than
$\tcode{F}_2$\iref{temp.constr.order}
\begin{example}
\begin{codeblock}
template <typename T = int>
Expand Down Expand Up @@ -3117,6 +3106,9 @@
a non-type
\grammarterm{template-parameter}\iref{temp.arg.nontype}.
\end{itemize}
If the target type contains a placeholder type,
placeholder type deduction is performed\iref{dcl.type.auto.deduct}, and
the remainder of this subclause uses the target type so deduced.
The \grammarterm{id-expression} can be preceded by the \tcode{\&} operator.
\begin{note}
Any redundant set of parentheses surrounding the function name is
Expand Down Expand Up @@ -3169,10 +3161,8 @@
\tcode{F0}
is eliminated if the set contains a second
non-template function that
is more constrained than
\tcode{F0}
according to
the partial ordering rules of \ref{temp.constr.order}.
is more partial-ordering-constrained than
\tcode{F0}\iref{temp.constr.order}.
Any given
function template specialization
\tcode{F1}
Expand Down Expand Up @@ -3208,8 +3198,9 @@
with type
\tcode{int(...)}
has been declared, and not because of any ambiguity.
For another example,
\end{example}

\begin{example}
\begin{codeblock}
struct X {
int f(int);
Expand All @@ -3226,6 +3217,21 @@
\end{codeblock}
\end{example}

\begin{example}
\begin{codeblock}
template<bool B> struct X {
void f(short) requires B;
void f(long);
template<typename> void g(short) requires B;
template<typename> void g(long);
};
void test() {
&X<true>::f; // error: ambiguous; constraints are not considered
&X<true>::g<int>; // error: ambiguous; constraints are not considered
}
\end{codeblock}
\end{example}

\pnum
\begin{note}
If \tcode{f} and \tcode{g} are both overload sets,
Expand Down
54 changes: 46 additions & 8 deletions source/templates.tex
Original file line number Diff line number Diff line change
Expand Up @@ -2133,6 +2133,22 @@
\end{codeblock}
\end{example}

\pnum
A non-template function \tcode{F1} is \defn{more partial-ordering-constrained}
than a non-template function \tcode{F2} if
\begin{itemize}
\item
they have the same non-object-parameter-type-lists\iref{dcl.fct}, and
\item
if they are member functions, both are direct members of the same class, and
\item
if both are non-static member functions,
they have the same types for their object parameters, and
\item
the declaration of \tcode{F1} is more constrained than
the declaration of \tcode{F2}.
\end{itemize}

\rSec1[temp.type]{Type equivalence}

\pnum
Expand Down Expand Up @@ -7866,10 +7882,11 @@
the parameter is treated as a non-deduced context.
\item
If the argument is an overload set (not containing function templates), trial
argument deduction is attempted using each of the members of the set. If
deduction succeeds for only one of the overload set members, that member is
used as the argument value for the deduction. If deduction succeeds for more than
one member of the overload set the parameter is treated as a non-deduced context.
argument deduction is attempted using each of the members of the set
whose associated constraints\iref{temp.constr.constr} are satisfied.
If all successful deductions yield the same deduced \tcode{A},
that deduced \tcode{A} is the result of deduction;
otherwise, the parameter is treated as a non-deduced context.
\end{itemize}

\pnum
Expand Down Expand Up @@ -7905,6 +7922,21 @@
\end{codeblock}
\end{example}

\pnum
\begin{example}
\begin{codeblock}
// All arguments for placeholder type deduction\iref{dcl.type.auto.deduct} yield the same deduced type.
template<bool B> struct X {
static void f(short) requires B; // \#1
static void f(short); // \#2
};
void test() {
auto x = &X<true>::f; // OK, deduces \tcode{void(*)(short)}, selects \#1
auto y = &X<false>::f; // OK, deduces \tcode{void(*)(short)}, selects \#2
}
\end{codeblock}
\end{example}

\rSec3[temp.deduct.funcaddr]{Deducing template arguments taking the address of a function template}

\pnum
Expand Down Expand Up @@ -8338,16 +8370,22 @@
deduction is being done.
\item
A function parameter for which the associated argument is an
overload set\iref{over.over}, and one or more of the following apply:
overload set such that one or more of the following apply:
\begin{itemize}
\item
more than one function matches the function parameter type (resulting in
an ambiguous deduction), or
functions whose associated constraints are satisfied and
that do not all have the same function type
match the function parameter type (resulting in an ambiguous deduction), or
\item
no function matches the function parameter type, or
no function whose associated constraints are satisfied
matches the function parameter type, or
\item
the overload set supplied as an argument contains one or more function templates.
\end{itemize}
\begin{tailnote}
A particular function from the overload set is selected\iref{over.over}
after template argument deduction has succeeded\iref{temp.over}.
\end{tailnote}
\item A function parameter for which the associated argument is an initializer
list\iref{dcl.init.list} but the parameter does not have
a type for which deduction from an initializer list is specified\iref{temp.deduct.call}.
Expand Down