Skip to content

Commit a8c41a9

Browse files
authored
Merge 2018-06 CWG Motion 16
Fixes #2128
2 parents 7f148c3 + 3b24b2d commit a8c41a9

File tree

9 files changed

+164
-111
lines changed

9 files changed

+164
-111
lines changed

source/compatibility.tex

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,6 +1917,27 @@
19171917

19181918
\rSec2[diff.cpp17.special]{\ref{special}: special member functions}
19191919

1920+
\diffrefs{class.ctor}{class.conv.fct}
1921+
\change
1922+
The class name can no longer be used parenthesized
1923+
immediately after an \tcode{explicit} \grammarterm{decl-specifier}
1924+
in a constructor declaration.
1925+
The \grammarterm{conversion-function-id} can no longer be used parenthesized
1926+
immediately after an \tcode{explicit} \grammarterm{decl-specifier}
1927+
in a conversion function declaration.
1928+
\rationale
1929+
Necessary for new functionality.
1930+
\effect
1931+
Valid \CppXVII{} code may fail to compile
1932+
in this International Standard. For example:
1933+
\begin{codeblock}
1934+
struct S {
1935+
explicit (S)(const S&); // ill-formed; previously well-formed
1936+
explicit (operator int)(); // ill-formed; previously well-formed
1937+
explicit(true) (S)(int); // OK
1938+
};
1939+
\end{codeblock}
1940+
19201941
\diffrefs{class.ctor}{class.dtor}
19211942
\change
19221943
A \grammarterm{simple-template-id}

source/declarations.tex

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,12 @@
499499
\begin{bnf}
500500
\nontermdef{function-specifier}\br
501501
\terminal{virtual}\br
502+
explicit-specifier
503+
\end{bnf}
504+
505+
\begin{bnf}
506+
\nontermdef{explicit-specifier}\br
507+
\terminal{explicit} \terminal{(} constant-expression \terminal{)}\br
502508
\terminal{explicit}
503509
\end{bnf}
504510

@@ -510,10 +516,22 @@
510516

511517
\pnum
512518
\indextext{specifier!\idxcode{explicit}}%
513-
The \tcode{explicit} specifier shall be used only in the declaration of
519+
An \grammarterm{explicit-specifier} shall be used only in the declaration of
514520
a constructor or conversion function within its class definition;
515521
see~\ref{class.conv.ctor} and~\ref{class.conv.fct}.
516522

523+
\pnum
524+
In an \grammarterm{explicit-specifier},
525+
the \grammarterm{constant-expression}, if supplied, shall be a
526+
contextually converted constant expression of type \tcode{bool}\iref{expr.const}.
527+
The \grammarterm{explicit-specifier} \tcode{explicit}
528+
without a \grammarterm{constant-expression} is equivalent to
529+
the \grammarterm{explicit-specifier} \tcode{explicit(true)}.
530+
If the constant expression evaluates to \tcode{true},
531+
the function is explicit. Otherwise, the function is not explicit.
532+
A \tcode{(} token that follows \tcode{explicit} is parsed as
533+
part of the \grammarterm{explicit-specifier}.
534+
517535
\rSec2[dcl.typedef]{The \tcode{typedef} specifier}%
518536
\indextext{specifier!\idxcode{typedef}}
519537

source/declarators.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -440,10 +440,11 @@
440440
\tcode{inline},
441441
\tcode{virtual},
442442
\tcode{constexpr},
443-
\tcode{explicit},
444443
or
445444
\tcode{typedef}
446-
specifier applies directly to each \grammarterm{declarator-id}
445+
specifier
446+
or an \grammarterm{explicit-specifier}
447+
applies directly to each \grammarterm{declarator-id}
447448
in an \grammarterm{init-declarator-list} or \grammarterm{member-declarator-list};
448449
the type specified for each \grammarterm{declarator-id} depends on
449450
both the \grammarterm{decl-specifier-seq} and its \grammarterm{declarator}.

source/lib-intro.tex

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,13 +834,6 @@
834834
the implementation provides explicit definitions for such member function
835835
signatures, or for virtual destructors that can be generated by default.
836836

837-
\pnum
838-
For the sake of exposition, the library clauses sometimes annotate
839-
constructors with \EXPLICIT{}. Such a constructor is conditionally declared
840-
as either explicit or non-explicit\iref{class.conv.ctor}.
841-
\begin{note} This is typically implemented by declaring two such constructors,
842-
of which at most one participates in overload resolution. \end{note}
843-
844837
\rSec3[operators]{Operators}
845838

846839
\pnum

source/macros.tex

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,8 +290,6 @@
290290
\newcommand{\unspecuniqtype}{\UNSP{unspecified unique type}}
291291
\newcommand{\unspecalloctype}{\UNSP{unspecified allocator type}}
292292

293-
\newcommand{\EXPLICIT}{\textit{\texttt{EXPLICIT}\nocorr}}
294-
295293
%% Manual insertion of italic corrections, for aligning in the presence
296294
%% of the above annotations.
297295
\newlength{\itcorrwidth}

source/overloading.tex

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,13 @@
609609
function template specializations
610610
are generated using template argument deduction~(\ref{temp.over},
611611
\ref{temp.deduct}).
612+
If a constructor template or conversion function template
613+
has an \grammarterm{explicit-specifier}
614+
whose \grammarterm{constant-expression} is value-dependent\iref{temp.dep},
615+
template argument deduction is performed first and then,
616+
if the context requires a candidate that
617+
is not explicit and the generated specialization is explicit\iref{dcl.fct.spec},
618+
it will be removed from the candidate set.
612619
Those candidates are then handled as candidate
613620
functions in the usual way.\footnote{The process of argument deduction fully
614621
determines the parameter types of
@@ -1436,7 +1443,7 @@
14361443

14371444
If the initializer list has no elements and \tcode{T} has a default constructor,
14381445
the first phase is omitted.
1439-
In copy-list-initialization, if an \tcode{explicit} constructor is
1446+
In copy-list-initialization, if an explicit constructor is
14401447
chosen, the initialization is ill-formed. \begin{note}
14411448
This differs from other situations~(\ref{over.match.ctor}, \ref{over.match.copy}),
14421449
where only converting constructors are considered for copy-initialization.
@@ -1514,10 +1521,11 @@
15141521
a single expression of type \cv{}~\tcode{U},
15151522
where \tcode{U} is a specialization of \tcode{C} or
15161523
a class derived from a specialization of \tcode{C}.
1517-
Each such notional constructor
1518-
is considered to be explicit if the function or function template was
1519-
generated from a constructor or \grammarterm{deduction-guide} that was
1520-
declared \tcode{explicit}.
1524+
If the function or function template was generated from
1525+
a constructor or \grammarterm{deduction-guide}
1526+
that had an \grammarterm{explicit-specifier},
1527+
each such notional constructor is considered to have
1528+
that same \grammarterm{explicit-specifier}.
15211529
All such notional constructors are considered to be
15221530
public members of the hypothetical class type.
15231531

source/special.tex

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
The \grammarterm{class-name} shall not be a \grammarterm{typedef-name}. In a constructor
104104
declaration, each \grammarterm{decl-specifier} in the optional
105105
\grammarterm{decl-specifier-seq} shall be \tcode{friend}, \tcode{inline},
106-
\tcode{explicit}, or \tcode{constexpr}.
106+
\tcode{constexpr}, or an \grammarterm{explicit-specifier}.
107107
\begin{example}
108108

109109
\begin{codeblock}
@@ -793,9 +793,7 @@
793793
\indextext{conversion!user-defined}%
794794

795795
\pnum
796-
A constructor declared without the
797-
\grammarterm{function-specifier}
798-
\tcode{explicit}
796+
A constructor that is not explicit\iref{dcl.fct.spec}
799797
specifies a conversion from
800798
the types of its parameters (if any)
801799
to the type of its class.

source/templates.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7238,9 +7238,11 @@
72387238
as part of the substitution
72397239
process.
72407240
\end{note}
7241-
Only invalid types and expressions in the immediate
7242-
context of the function type and its template parameter types can result in a deduction
7243-
failure.
7241+
Only invalid types and expressions in the immediate context of
7242+
the function type,
7243+
its template parameter types,
7244+
and its \grammarterm{explicit-specifier}
7245+
can result in a deduction failure.
72447246
\begin{note}
72457247
The substitution into types and expressions can result
72467248
in effects such as the instantiation of class template specializations and/or

0 commit comments

Comments
 (0)