Skip to content

Commit 871ef20

Browse files
committed
Merge 2020-11 CWG Motion 1
P2238R0 Core Language Working Group "tentatively ready" Issues for the November, 2020 virtual meeting
2 parents d5e8108 + 6fe1207 commit 871ef20

File tree

3 files changed

+63
-43
lines changed

3 files changed

+63
-43
lines changed

source/declarations.tex

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6581,7 +6581,7 @@
65816581
that is a function template whose first template parameter
65826582
is a non-type parameter,
65836583
the initializer is
6584-
\tcode{\exposid{e}.get<i>()}. Otherwise, the initializer is \tcode{get<i>(\exposid{e})},
6584+
\tcode{\exposidnc{e}.get<i>()}. Otherwise, the initializer is \tcode{get<i>(\exposid{e})},
65856585
where \tcode{get} is looked up in the associated namespaces\iref{basic.lookup.argdep}.
65866586
In either case, \tcode{get<i>} is interpreted as a \grammarterm{template-id}.
65876587
\begin{note}
@@ -6610,7 +6610,7 @@
66106610
all of \tcode{E}'s non-static data members
66116611
shall be direct members of \tcode{E} or
66126612
of the same base class of \tcode{E},
6613-
well-formed when named as \tcode{\exposid{e}.\placeholder{name}}
6613+
well-formed when named as \tcode{\exposidnc{e}.\placeholder{name}}
66146614
in the context of the structured binding,
66156615
\tcode{E} shall not have an anonymous union member, and
66166616
the number of elements in the \grammarterm{identifier-list} shall be
@@ -6620,16 +6620,20 @@
66206620
(in declaration order),
66216621
each \tcode{v}$_i$ is the
66226622
name of an lvalue that refers to the member \tcode{m}$_i$ of \exposid{e} and
6623-
whose type is \cv{}~$\tcode{T}_i$, where $\tcode{T}_i$ is the declared type of
6624-
that member; the referenced type is \cv{}~$\tcode{T}_i$. The lvalue is a
6623+
whose type is
6624+
that of \tcode{\exposidnc{e}.$\tcode{m}_i$}\iref{expr.ref};
6625+
the referenced type is
6626+
the declared type of $\tcode{m}_i$ if that type is a reference type, or
6627+
the type of \tcode{\exposidnc{e}.$\tcode{m}_i$} otherwise.
6628+
The lvalue is a
66256629
bit-field if that member is a bit-field.
66266630
\begin{example}
66276631
\begin{codeblock}
6628-
struct S { int x1 : 2; volatile double y1; };
6632+
struct S { mutable int x1 : 2; volatile double y1; };
66296633
S f();
66306634
const auto [ x, y ] = f();
66316635
\end{codeblock}
6632-
The type of the \grammarterm{id-expression} \tcode{x} is ``\tcode{const int}'',
6636+
The type of the \grammarterm{id-expression} \tcode{x} is ``\tcode{int}'',
66336637
the type of the \grammarterm{id-expression} \tcode{y} is ``\tcode{const volatile double}''.
66346638
\end{example}
66356639

@@ -8309,8 +8313,9 @@
83098313
\indextext{class!linkage specification}%
83108314
A C language linkage is ignored
83118315
in determining the language linkage of
8312-
the names of class members and the
8313-
function type of class member functions.
8316+
the names of class members,
8317+
the names of friend functions with a trailing \grammarterm{requires-clause}, and
8318+
the function type of class member functions.
83148319
\begin{example}
83158320
\begin{codeblock}
83168321
extern "C" typedef void FUNC_c();

source/statements.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -924,8 +924,10 @@
924924

925925
\pnum
926926
If \placeholder{p}\tcode{.return_void()} is a valid expression,
927-
flowing off the end of a coroutine is equivalent to a \tcode{co_return} with no operand;
928-
otherwise flowing off the end of a coroutine results in undefined behavior.
927+
flowing off the end of a coroutine's \grammarterm{function-body}
928+
is equivalent to a \tcode{co_return} with no operand;
929+
otherwise flowing off the end of a coroutine's \grammarterm{function-body}
930+
results in undefined behavior.
929931

930932
\rSec2[stmt.goto]{The \tcode{goto} statement}%
931933
\indextext{statement!\idxcode{goto}}

source/templates.tex

Lines changed: 46 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4532,9 +4532,10 @@
45324532
or a substatement of a constexpr if statement\iref{stmt.if} within a template
45334533
and the template is not instantiated, or
45344534
\item
4535-
no substitution of template arguments
4536-
into a \grammarterm{type-constraint} or \grammarterm{requires-clause}
4537-
would result in a valid expression, or
4535+
any \grammarterm{constraint-expression} in the program, introduced or otherwise,
4536+
has (in its normal form) an atomic constraint $A$ where
4537+
no satisfaction check of $A$ could be well-formed and
4538+
no satisfaction check of $A$ is performed, or
45384539
\item
45394540
every valid specialization of a variadic template requires an empty template
45404541
parameter pack, or
@@ -5349,6 +5350,8 @@
53495350
an array type whose element type is dependent or whose
53505351
bound (if any) is value-dependent,
53515352
\item
5353+
a function type whose parameters include one or more function parameter packs,
5354+
\item
53525355
a function type whose exception specification is value-dependent,
53535356
\item
53545357
denoted by a \grammarterm{simple-template-id}
@@ -7596,13 +7599,52 @@
75967599

75977600
When all template arguments have been deduced or obtained from
75987601
default template arguments, all uses of template parameters in
7599-
the template parameter list of the template and the function type
7602+
the template parameter list of the template
76007603
are replaced with the corresponding deduced
76017604
or default argument values. If the substitution results in an
76027605
invalid type, as described above, type deduction fails.
76037606
If the function template has associated constraints\iref{temp.constr.decl},
76047607
those constraints are checked for satisfaction\iref{temp.constr.constr}.
76057608
If the constraints are not satisfied, type deduction fails.
7609+
In the context of a function call, if type deduction has not yet failed, then
7610+
for those function parameters for which the function call has arguments,
7611+
each function parameter with a type that was non-dependent
7612+
before substitution of any explicitly-specified template arguments
7613+
is checked against its corresponding argument;
7614+
if the corresponding argument cannot be implicitly converted
7615+
to the parameter type, type deduction fails.
7616+
\begin{note}
7617+
Overload resolution will check the other parameters, including
7618+
parameters with dependent types in which
7619+
no template parameters participate in template argument deduction and
7620+
parameters that became non-dependent due to substitution of
7621+
explicitly-specified template arguments.
7622+
\end{note}
7623+
If type deduction has not yet failed, then
7624+
all uses of template parameters in the function type are
7625+
replaced with the corresponding deduced or default argument values.
7626+
If the substitution results in an invalid type, as described above,
7627+
type deduction fails.
7628+
\begin{example}
7629+
\begin{codeblock}
7630+
template <class T> struct Z {
7631+
typedef typename T::x xx;
7632+
};
7633+
template <class T> concept C = requires { typename T::A; };
7634+
template <C T> typename Z<T>::xx f(void *, T); // \#1
7635+
template <class T> void f(int, T); // \#2
7636+
struct A {} a;
7637+
struct ZZ {
7638+
template <class T, class = typename Z<T>::xx> operator T *();
7639+
operator int();
7640+
};
7641+
int main() {
7642+
ZZ zz;
7643+
f(1, a); // OK, deduction fails for \#1 because there is no conversion from \tcode{int} to \tcode{void*}
7644+
f(zz, 42); // OK, deduction fails for \#1 because \tcode{C<int>} is not satisfied
7645+
}
7646+
\end{codeblock}
7647+
\end{example}
76067648

76077649
\pnum
76087650
At certain points in the template argument deduction process it is necessary
@@ -8160,35 +8202,6 @@
81608202
\end{codeblock}
81618203
\end{example}
81628204

8163-
\pnum
8164-
If deduction succeeds for all parameters that contain
8165-
\grammarterm{template-parameter}{s} that participate in template argument
8166-
deduction, and all template arguments are explicitly specified, deduced,
8167-
or obtained from default template arguments, remaining parameters are then
8168-
compared with the corresponding arguments. For each remaining parameter
8169-
\tcode{P} with a type that was non-dependent before substitution of any
8170-
explicitly-specified template arguments, if the corresponding argument
8171-
\tcode{A} cannot be implicitly converted to \tcode{P}, deduction fails.
8172-
\begin{note}
8173-
Parameters with dependent types in which no \grammarterm{template-parameter}{s}
8174-
participate in template argument deduction, and parameters that became
8175-
non-dependent due to substitution of explicitly-specified template arguments,
8176-
will be checked during overload resolution.
8177-
\end{note}
8178-
\begin{example}
8179-
\begin{codeblock}
8180-
template <class T> struct Z {
8181-
typedef typename T::x xx;
8182-
};
8183-
template <class T> typename Z<T>::xx f(void *, T); // \#1
8184-
template <class T> void f(int, T); // \#2
8185-
struct A {} a;
8186-
int main() {
8187-
f(1, a); // OK, deduction fails for \#1 because there is no conversion from \tcode{int} to \tcode{void*}
8188-
}
8189-
\end{codeblock}
8190-
\end{example}
8191-
81928205
\rSec3[temp.deduct.funcaddr]{Deducing template arguments taking the address of a function template}
81938206

81948207
\pnum

0 commit comments

Comments
 (0)