Skip to content

Commit 9acd179

Browse files
committed
Merge 2017-07 CWG Motion 2
2 parents 2cd4452 + 4181868 commit 9acd179

File tree

6 files changed

+90
-20
lines changed

6 files changed

+90
-20
lines changed

source/basic.tex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,6 +722,12 @@
722722
variable~(\ref{dcl.fct.def}) is immediately before the
723723
\grammarterm{function-body} of a function definition.
724724

725+
\pnum
726+
The point of declaration for the variable or the structured bindings
727+
declared in the \grammarterm{for-range-declaration}
728+
of a range-based \tcode{for} statement~(\ref{stmt.ranged})
729+
is immediately after the \grammarterm{for-range-initializer}.
730+
725731
\pnum
726732
The point of declaration for a template parameter is immediately after its complete
727733
\grammarterm{template-parameter}. \begin{example}
@@ -4061,7 +4067,7 @@
40614067
\item
40624068
they are the same object, or
40634069
\item
4064-
one is a standard-layout union object and
4070+
one is a union object and
40654071
the other is a non-static data member of that object~(\ref{class.union}), or
40664072
\item
40674073
one is a standard-layout class object and

source/classes.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1525,9 +1525,9 @@
15251525
of its non-static data members. Each non-static data member is allocated
15261526
as if it were the sole member of a struct.
15271527
\begin{note}
1528-
A standard-layout union object and its non-static data members are
1528+
A union object and its non-static data members are
15291529
pointer-interconvertible~(\ref{basic.compound}, \ref{expr.static.cast}).
1530-
As a consequence, all non-static data members of such a
1530+
As a consequence, all non-static data members of a
15311531
union object have the same address.
15321532
\end{note}
15331533

source/declarations.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3022,7 +3022,8 @@
30223022

30233023
\pnum
30243024
\indextext{overloading!using-declaration and}%
3025-
For the purpose of overload resolution, the functions that are
3025+
For the purpose of forming a set of candidates during overload resolution,
3026+
the functions that are
30263027
introduced by a \grammarterm{using-declaration} into a derived class
30273028
are treated as though they were members of the derived class. In
30283029
particular, the implicit \tcode{this} parameter shall be treated as if
@@ -3037,6 +3038,10 @@
30373038
of an object of class type, all subobjects other than the base class
30383039
from which the constructor originated
30393040
are implicitly initialized~(\ref{class.inhctor.init}).
3041+
\begin{note}
3042+
A member of a derived class is sometimes preferred to a member of a base class
3043+
if they would otherwise be ambiguous~(\ref{over.match.best}).
3044+
\end{note}
30403045

30413046
\pnum
30423047
\indextext{access control!using-declaration and}%

source/expressions.tex

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -376,11 +376,12 @@
376376
the declaration of a static member function (although its type and value category
377377
are defined within a static member function as they are within a non-static
378378
member function). \begin{note} This is because declaration matching does not
379-
occur until the complete declarator is known. \end{note} Unlike the object
380-
expression in other contexts, \tcode{*this} is not required to be of complete
381-
type for purposes of class member access~(\ref{expr.ref}) outside the member
382-
function body. \begin{note} Only class members declared prior to the declaration
383-
are visible. \end{note}
379+
occur until the complete declarator is known. \end{note}
380+
\begin{note}
381+
In a \grammarterm{trailing-return-type},
382+
the class being defined is not required to be complete
383+
for purposes of class member access~(\ref{expr.ref}).
384+
Class members declared later are not visible.
384385
\begin{example}
385386
\begin{codeblock}
386387
struct A {
@@ -391,6 +392,7 @@
391392
template auto A::f(int t) -> decltype(t + g());
392393
\end{codeblock}
393394
\end{example}
395+
\end{note}
394396

395397
\pnum
396398
Otherwise, if a \grammarterm{member-declarator} declares a non-static data
@@ -1843,9 +1845,15 @@
18431845
\pnum
18441846
\indextext{type!incomplete}%
18451847
For the first option (dot) the first expression
1846-
shall be a glvalue having complete class type.
1848+
shall be a glvalue having class type.
18471849
For the second option (arrow) the first expression
1848-
shall be a prvalue having pointer to complete class type.
1850+
shall be a prvalue having pointer to class type.
1851+
In both cases, the class type shall be complete
1852+
unless the class member access appears in the definition of that class.
1853+
\begin{note}
1854+
If the class is incomplete, lookup in the complete class type
1855+
is required to refer to the same declaration~(\ref{basic.scope.class}).
1856+
\end{note}
18491857
The expression \tcode{E1->E2} is
18501858
converted to the equivalent form \tcode{(*(E1)).E2}; the remainder of
18511859
\ref{expr.ref}~will address only the first option (dot).\footnote{Note that

source/overloading.tex

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@
634634
with the set of non-template candidate functions.
635635

636636
\pnum
637-
A defaulted move constructor or assignment operator~(\ref{class.copy}) that is
637+
A defaulted move special function~(\ref{class.copy}) that is
638638
defined as deleted is excluded from the set of candidate functions in all
639639
contexts.
640640

@@ -1676,6 +1676,29 @@
16761676
according to the partial ordering rules described in~\ref{temp.func.order},
16771677
or, if not that,
16781678

1679+
\item
1680+
\tcode{F1} is a constructor for a class \tcode{D},
1681+
\tcode{F2} is a constructor for a base class \tcode{B} of \tcode{D}, and
1682+
for all arguments
1683+
the corresponding parameters of \tcode{F1} and \tcode{F2} have the same type.
1684+
\begin{example}
1685+
\begin{codeblock}
1686+
struct A {
1687+
A(int = 0);
1688+
};
1689+
1690+
struct B: A {
1691+
using A::A;
1692+
B();
1693+
};
1694+
1695+
int main() {
1696+
B b; // OK, \tcode{B::B()}
1697+
}
1698+
\end{codeblock}
1699+
\end{example}
1700+
or, if not that,
1701+
16791702
\item
16801703
\tcode{F1} is generated from a
16811704
\grammarterm{deduction-guide}~(\ref{over.match.class.deduct})

source/templates.tex

Lines changed: 36 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4889,13 +4889,18 @@
48894889

48904890
\pnum
48914891
If the explicit instantiation is for a class or member class, the
4892-
\grammarterm{elaborated-type-specifier} in the \grammarterm{declaration} shall
4893-
include a \grammarterm{simple-template-id}. If the explicit instantiation is for
4892+
\grammarterm{elaborated-type-specifier} in the \grammarterm{declaration}
4893+
shall include a \grammarterm{simple-template-id};
4894+
otherwise, the \grammarterm{declaration}
4895+
shall be a \grammarterm{simple-declaration} whose \grammarterm{init-declarator-list}
4896+
comprises a single \grammarterm{init-declarator}
4897+
that does not have an \grammarterm{initializer}.
4898+
If the explicit instantiation is for
48944899
a function or member function,
48954900
the
48964901
\grammarterm{unqualified-id}
48974902
in the
4898-
\grammarterm{declaration}
4903+
\grammarterm{declarator}
48994904
shall be either a
49004905
\grammarterm{template-id}
49014906
or, where all template arguments can be deduced, a
@@ -4915,9 +4920,9 @@
49154920
the name of the class template specialization in the
49164921
\grammarterm{qualified-id}
49174922
for the member name shall be a \grammarterm{simple-template-id}.
4918-
If the explicit instantiation is for a variable, the
4919-
\grammarterm{unqualified-id} in the declaration shall be a
4920-
\grammarterm{template-id}.
4923+
If the explicit instantiation is for a variable template specialization,
4924+
the \grammarterm{unqualified-id} in the \grammarterm{declarator}
4925+
shall be a \grammarterm{simple-template-id}.
49214926
An explicit instantiation shall appear in an enclosing namespace
49224927
of its template. If the name declared in the explicit
49234928
instantiation is an unqualified name, the explicit instantiation
@@ -4958,6 +4963,28 @@
49584963
of the explicit instantiation names an implicitly-declared special member
49594964
function (Clause~\ref{special}), the program is ill-formed.
49604965

4966+
\pnum
4967+
The \grammarterm{declaration} in an \grammarterm{explicit-instantiation} and the \grammarterm{declaration} produced by the corresponding substitution into the templated function, variable, or class are two declarations of the same entity.
4968+
\begin{note}
4969+
These declarations are required to have matching types as specified in~\ref{basic.link}, except as specified in~\ref{except.spec}.
4970+
\begin{example}
4971+
\begin{codeblock}
4972+
template<typename T> T var = {};
4973+
template float var<float>; // OK, instantiated variable has type \tcode{float}
4974+
template int var<int[16]>[]; // OK, absence of major array bound is permitted
4975+
template int *var<int>; // error: instantiated variable has type \tcode{int}
4976+
4977+
template<typename T> auto av = T();
4978+
template int av<int>; // OK, variable with type \tcode{int} can be redeclared with type \tcode{auto}
4979+
4980+
template<typename T> auto f() {}
4981+
template void f<int>(); // error: function with deduced return type
4982+
// redeclared with non-deduced return type~(\ref{dcl.spec.auto})
4983+
\end{codeblock}
4984+
\end{example}
4985+
\end{note}
4986+
Despite its syntactic form, the \grammarterm{declaration} in an \grammarterm{explicit-instantiation} for a variable is not itself a definition and does not conflict with the definition instantiated by an explicit instantiation definition for that variable.
4987+
49614988
\pnum
49624989
For a given set of template arguments, if an explicit
49634990
instantiation of a template appears after a declaration of
@@ -5033,8 +5060,9 @@
50335060
literal types,
50345061
variables of reference types, and class template specializations,
50355062
explicit instantiation declarations have the
5036-
effect of suppressing the implicit instantiation of the entity to which they
5037-
refer. \begin{note} The intent is that an inline function that is the
5063+
effect of suppressing the implicit instantiation
5064+
of the definition of the entity to which they refer.
5065+
\begin{note} The intent is that an inline function that is the
50385066
subject of an explicit instantiation declaration will still be implicitly
50395067
instantiated when odr-used~(\ref{basic.def.odr}) so that the body can be considered for inlining, but
50405068
that no out-of-line copy of the inline function would be generated in the

0 commit comments

Comments
 (0)