Skip to content

Commit a22928a

Browse files
authored
Merge 2018-06 CWG Motion 2
Fixes #2114
2 parents 985fe9d + 5616905 commit a22928a

File tree

4 files changed

+68
-11
lines changed

4 files changed

+68
-11
lines changed

source/basic.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -808,9 +808,14 @@
808808

809809
\pnum
810810
The point of declaration for a function-local predefined
811-
variable\iref{dcl.fct.def} is immediately before the
811+
variable\iref{dcl.fct.def.general} is immediately before the
812812
\grammarterm{function-body} of a function definition.
813813

814+
\pnum
815+
The point of declaration of a structured binding\iref{dcl.struct.bind}
816+
is immediately after
817+
the \grammarterm{identifier-list} of the structured binding declaration.
818+
814819
\pnum
815820
The point of declaration for the variable or the structured bindings
816821
declared in the \grammarterm{for-range-declaration}

source/declarators.tex

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1644,7 +1644,10 @@
16441644
\grammarterm{parameter-declaration}{} this
16451645
\grammarterm{initializer-clause}{}
16461646
is used as a default argument.
1647-
Default arguments will be used in calls where trailing arguments are missing.
1647+
\begin{note}
1648+
Default arguments will be used in calls
1649+
where trailing arguments are missing\iref{expr.call}.
1650+
\end{note}
16481651

16491652
\pnum
16501653
\indextext{argument!example of default}%
@@ -1709,7 +1712,8 @@
17091712
In
17101713
a given function declaration, each parameter subsequent to a
17111714
parameter with a default argument shall have a default argument
1712-
supplied in this or a previous declaration
1715+
supplied in this or a previous declaration,
1716+
unless the parameter was expanded from a parameter pack,
17131717
or shall be a function parameter pack.
17141718
A default argument
17151719
shall not be redefined by a later declaration (not even to the
@@ -1735,6 +1739,10 @@
17351739
void n() {
17361740
f(6); // OK, calls \tcode{f(6, 7)}
17371741
}
1742+
template<class ... T> struct C {
1743+
void f(int n = 0, T...);
1744+
};
1745+
C<int> c; // OK, instantiates declaration \tcode{void C::f(int n = 0, int)}
17381746
\end{codeblock}
17391747
\end{example}
17401748
For a given inline function defined in different translation units,
@@ -2289,6 +2297,11 @@
22892297
\tcode{E} is never a reference type\iref{expr.prop}.
22902298
\end{note}
22912299

2300+
\pnum
2301+
If the \grammarterm{initializer} refers to
2302+
one of the names introduced by the structured binding declaration,
2303+
the program is ill-formed.
2304+
22922305
\pnum
22932306
If \tcode{E} is an array type with element type \tcode{T}, the number
22942307
of elements in the \grammarterm{identifier-list} shall be equal to the
@@ -3004,7 +3017,7 @@
30043017
\item
30053018
Otherwise, the element is copy-initialized
30063019
from the corresponding \grammarterm{initializer-clause}
3007-
or the \grammarterm{brace-or-equal-initializer}
3020+
or is initialized with the \grammarterm{brace-or-equal-initializer}
30083021
of the corresponding \grammarterm{designated-initializer-clause}.
30093022
If that initializer is of the form
30103023
\grammarterm{assignment-expression} or

source/expressions.tex

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,10 @@
677677

678678
\pnum
679679
\indextext{identifier}%
680-
An \grammarterm{identifier} is an \grammarterm{id-expression} provided it has
681-
been suitably declared\iref{dcl.dcl}.
680+
An \grammarterm{identifier} is only
681+
an \grammarterm{id-expression} if it has
682+
been suitably declared\iref{dcl.dcl}
683+
or if it appears as part of a \grammarterm{declarator-id}\iref{dcl.decl}.
682684
\begin{note}
683685
For \grammarterm{operator-function-id}{s}, see~\ref{over.oper}; for
684686
\grammarterm{conversion-function-id}{s}, see~\ref{class.conv.fct}; for
@@ -2237,12 +2239,21 @@
22372239
\indextext{function argument|see{argument}}%
22382240
\indextext{function parameter|see{parameter}}%
22392241
\indextext{initialization!parameter}%
2240-
When a function is called, each parameter\iref{dcl.fct} shall be
2242+
When a function is called, each parameter\iref{dcl.fct} is
22412243
initialized~(\ref{dcl.init}, \ref{class.copy}, \ref{class.ctor}) with
22422244
its corresponding argument.
2245+
If there is no corresponding argument,
2246+
the default argument for the parameter is used;
2247+
the program is ill-formed if one is not present.
2248+
\begin{example}
2249+
\begin{codeblock}
2250+
template<typename ...T> int f(int n = 0, T ...t);
2251+
int x = f<int>(); // error: no argument for second function parameter
2252+
\end{codeblock}
2253+
\end{example}
22432254
If the function is a non-static member
22442255
function, the \tcode{this} parameter of the function\iref{class.this}
2245-
shall be initialized with a pointer to the object of the call, converted
2256+
is initialized with a pointer to the object of the call, converted
22462257
as if by an explicit type conversion\iref{expr.cast}.
22472258
\begin{note}
22482259
There is no access or ambiguity checking on this conversion; the access
@@ -2431,7 +2442,7 @@
24312442
expression\iref{expr.cast}.
24322443
\indextext{type!incomplete}%
24332444
Otherwise, if the type is \cv{}~\tcode{void}
2434-
and the initializer is \tcode{()}
2445+
and the initializer is \tcode{()} or \tcode{\{\}}
24352446
(after pack expansion, if any),
24362447
the expression is a prvalue of the specified type
24372448
that performs no initialization.

source/overloading.tex

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -630,8 +630,36 @@
630630

631631
\pnum
632632
A defaulted move special function\iref{class.copy} that is
633-
defined as deleted is excluded from the set of candidate functions in all
634-
contexts.
633+
defined as deleted is excluded from the set of candidate functions
634+
in all contexts.
635+
A constructor inherited from class type \tcode{C}\iref{class.inhctor.init}
636+
that has a first parameter of type ``reference to \cvqual{cv1} \tcode{P}''
637+
(including such a constructor instantiated from a template)
638+
is excluded from the set of candidate functions
639+
when constructing an object of type \cvqual{cv2} \tcode{D}
640+
if the argument list has exactly one argument and
641+
\tcode{C} is reference-related to \tcode{P} and
642+
\tcode{P} is reference-related to \tcode{D}.
643+
\begin{example}
644+
\begin{codeblock}
645+
struct A {
646+
A();
647+
A(A &&); // \#1
648+
template<typename T> A(T &&); // \#2
649+
};
650+
struct B : A {
651+
using A::A;
652+
B(const B &); // \#3
653+
B(B &&) = default; // \#4, implicitly deleted
654+
655+
struct X { X(X &&) = delete; } x;
656+
};
657+
extern B b1;
658+
B b2 = static_cast<B&&>(b1); // calls \#3: \#1, \#2, and \#4 are not viable
659+
struct C { operator B&&(); };
660+
B b3 = C(); // calls \#3
661+
\end{codeblock}
662+
\end{example}
635663

636664
\rSec3[over.match.call]{Function call syntax}%
637665
\indextext{overloading!resolution!function call syntax|(}

0 commit comments

Comments
 (0)