Skip to content

Commit 985fe9d

Browse files
authored
Merge 2018-06 CWG Motion 1
Fixes #2113
2 parents fbd725c + 5274b2e commit 985fe9d

File tree

5 files changed

+73
-30
lines changed

5 files changed

+73
-30
lines changed

source/basic.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@
614614
\indextext{region!declarative}%
615615
\indextext{scope!potential}%
616616
\defn{declarative region}, which is the largest part of the program
617-
in which that name is \defn{valid}, that is, in which that name may
617+
in which that name is valid, that is, in which that name may
618618
be used as an unqualified name to refer to the same entity. In general,
619619
each particular name is valid only within some possibly discontiguous
620620
portion of program text called its \defn{scope}. To determine the
@@ -4156,7 +4156,7 @@
41564156
one is a standard-layout class object and
41574157
the other is the first non-static data member of that object, or,
41584158
if the object has no non-static data members,
4159-
the first base class subobject of that object\iref{class.mem}, or
4159+
any base class subobject of that object\iref{class.mem}, or
41604160
\item
41614161
there exists an object \placeholder{c} such that
41624162
\placeholder{a} and \placeholder{c} are pointer-interconvertible, and

source/classes.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -801,10 +801,12 @@
801801

802802
\pnum
803803
If a standard-layout class object has any non-static data members, its address
804-
is the same as the address of its first non-static data member. Otherwise, its
805-
address is the same as the address of its first base class subobject (if any).
804+
is the same as the address of its first non-static data member
805+
if that member is not a bit-field. Its
806+
address is also the same as the address of each of its base class subobjects.
806807
\begin{note}
807-
There might therefore be unnamed padding within a standard-layout struct object, but
808+
There might therefore be unnamed padding within a standard-layout struct object
809+
inserted by an implementation, but
808810
not at its beginning, as necessary to achieve appropriate alignment.
809811
\end{note}
810812
\begin{note}

source/declarators.tex

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2315,7 +2315,10 @@
23152315
and
23162316
the number of elements in
23172317
the \grammarterm{identifier-list} shall be equal to the value of that
2318-
expression. The \grammarterm{unqualified-id} \tcode{get} is looked up
2318+
expression.
2319+
Let \tcode{i} be an index prvalue of type \tcode{std::size_t}
2320+
corresponding to $\tcode{v}_\tcode{i}$.
2321+
The \grammarterm{unqualified-id} \tcode{get} is looked up
23192322
in the scope of \tcode{E} by class member access lookup\iref{basic.lookup.classref},
23202323
and if that finds at least one declaration
23212324
that is a function template whose first template parameter

source/expressions.tex

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5431,10 +5431,14 @@
54315431

54325432
\begin{itemize}
54335433
\item if \tcode{T1} and \tcode{T2} are the same class type
5434-
(ignoring cv-qualification), or one is a base class of the other, and
5434+
(ignoring cv-qualification) and
54355435
\tcode{T2} is at least as cv-qualified as \tcode{T1},
54365436
the target type is \tcode{T2},
54375437

5438+
\item otherwise, if \tcode{T2} is a base class of \tcode{T1},
5439+
the target type is \cvqual{cv1} \tcode{T2}, where \cvqual{cv1}
5440+
denotes the cv-qualifiers of \tcode{T1},
5441+
54385442
\item otherwise, the target type is the type that \tcode{E2} would have
54395443
after applying the
54405444
lvalue-to-rvalue\iref{conv.lval},

source/templates.tex

Lines changed: 57 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -962,6 +962,45 @@
962962
A \grammarterm{template-id} that names an alias template
963963
specialization is a \grammarterm{type-name}.
964964

965+
\pnum
966+
A \grammarterm{template-id} is \defnx{valid}{\idxgram{template-id}!valid} if
967+
\begin{itemize}
968+
\item
969+
there are at most as many arguments as there are parameters
970+
or a parameter is a template parameter pack\iref{temp.variadic},
971+
972+
\item
973+
there is an argument for each non-deducible non-pack parameter
974+
that does not have a default \grammarterm{template-argument},
975+
976+
\item
977+
each \grammarterm{template-argument} matches the corresponding
978+
\grammarterm{template-parameter}\iref{temp.arg},
979+
980+
\item
981+
substitution of each template argument into the following
982+
template parameters (if any) succeeds, and
983+
984+
\item
985+
if the \grammarterm{template-id} is non-dependent,
986+
the associated constraints are satisfied as specified in the next paragraph.
987+
\end{itemize}
988+
A \grammarterm{simple-template-id} shall be valid unless it names a
989+
function template specialization\iref{temp.deduct}.
990+
\begin{example}
991+
\begin{codeblock}
992+
template<class T, T::type n = 0> class X;
993+
struct S {
994+
using type = int;
995+
};
996+
using T1 = X<S, int, int>; // error: too many arguments
997+
using T2 = X<>; // error: no default argument for first template parameter
998+
using T3 = X<1>; // error: value \tcode{1} does not match type-parameter
999+
using T4 = X<int>; // error: substitution failure for second template parameter
1000+
using T5 = X<S>; // OK
1001+
\end{codeblock}
1002+
\end{example}
1003+
9651004
\pnum
9661005
When the \grammarterm{template-name}
9671006
of a \grammarterm{simple-template-id}
@@ -5092,6 +5131,13 @@
50925131
declared with a type
50935132
that contains a placeholder type\iref{dcl.spec.auto},
50945133

5134+
\item
5135+
an
5136+
\grammarterm{identifier}
5137+
associated by name lookup with
5138+
a variable declared with a type that contains a placeholder type\iref{dcl.spec.auto}
5139+
where the initializer is type-dependent,
5140+
50955141
\item
50965142
an \grammarterm{identifier} associated by name lookup with one or more
50975143
declarations of member functions of the current instantiation declared
@@ -7026,30 +7072,11 @@
70267072
\end{example}
70277073

70287074
\pnum
7029-
When an explicit template argument list is specified, if the template
7030-
arguments are not compatible with the template parameter list or do
7031-
not result in a valid function type as described below, type
7032-
deduction fails. Specifically, the following steps are performed when
7033-
evaluating an explicitly specified template argument list with respect
7034-
to a given function template:
7035-
\begin{itemize}
7036-
\item If the specified template arguments do not match the template
7037-
parameters in
7038-
kind (i.e., type, non-type, template), or if there
7039-
are more arguments than there are parameters
7040-
and no parameter is a template parameter pack, or if there is not
7041-
an argument for each non-pack parameter,
7042-
type deduction fails.
7043-
7044-
\item If any non-type argument does not match the type of the
7045-
corresponding non-type
7046-
template parameter, and is not convertible to the type of the
7047-
corresponding non-type parameter as specified in~\ref{temp.arg.nontype},
7075+
When an explicit template argument list is specified, if the
7076+
given \grammarterm{template-id} is not valid\iref{temp.names},
70487077
type deduction fails.
7049-
7050-
\item The specified template argument values are substituted for the
7078+
Otherwise, the specified template argument values are substituted for the
70517079
corresponding template parameters as specified below.
7052-
\end{itemize}
70537080

70547081
\pnum
70557082
After this substitution is performed, the function parameter type
@@ -7146,6 +7173,9 @@
71467173
inside \tcode{sizeof}, \tcode{decltype}, and other contexts that allow non-constant
71477174
expressions. The substitution proceeds in lexical order and stops when
71487175
a condition that causes deduction to fail is encountered.
7176+
If substitution into different declarations of the same function template would
7177+
cause template instantiations to occur in a different order or not at all,
7178+
the program is ill-formed; no diagnostic required.
71497179
\begin{note}
71507180
The equivalent substitution in exception specifications is
71517181
done only when the \grammarterm{noexcept-specifier} is instantiated,
@@ -7159,10 +7189,14 @@
71597189
template <class T> void f(...) { }
71607190
template <class T> auto g(typename A<T>::X) -> typename T::X;
71617191
template <class T> void g(...) { }
7192+
template <class T> typename T::X h(typename A<T>::X);
7193+
template <class T> auto h(typename A<T>::X) -> typename T::X; // redeclaration
7194+
template <class T> void h(...) { }
71627195

7163-
void h() {
7196+
void x() {
71647197
f<int>(0); // OK, substituting return type causes deduction to fail
71657198
g<int>(0); // error, substituting parameter type instantiates \tcode{A<int>}
7199+
h<int>(0); // ill-formed, no diagnostic required
71667200
}
71677201
\end{codeblock}
71687202
\end{example}

0 commit comments

Comments
 (0)