Skip to content

Commit 3b24b2d

Browse files
committed
[diff.cpp17] Correct description of explicit(bool) compatibility.
Parenthesized names for explicit constructors and conversion functions are still valid if the name doesn't immediately follow the explicit keyword. Add an example using explicit(true) as a hint indicating how to get the same effect. Change affected subclauses from [dcl.fct] to the somewhat-more-precise [class.ctor] and [class.conv.fct].
1 parent 24fef0e commit 3b24b2d

File tree

1 file changed

+21
-20
lines changed

1 file changed

+21
-20
lines changed

source/compatibility.tex

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1917,41 +1917,42 @@
19171917

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

1920-
\diffrefs{class.ctor}{class.dtor}
1920+
\diffrefs{class.ctor}{class.conv.fct}
19211921
\change
1922-
A \grammarterm{simple-template-id}
1923-
is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor.
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.
19241928
\rationale
1925-
Remove potentially error-prone option for redundancy.
1929+
Necessary for new functionality.
19261930
\effect
19271931
Valid \CppXVII{} code may fail to compile
19281932
in this International Standard. For example:
19291933
\begin{codeblock}
1930-
template<class T>
1931-
struct A {
1932-
A<T>(); // error: \grammarterm{simple-template-id} not allowed for constructor
1933-
A(int); // OK, \grammarterm{injected-class-name} used
1934-
~A<T>(); // error: \grammarterm{simple-template-id} not allowed for destructor
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
19351938
};
19361939
\end{codeblock}
19371940

1938-
\rSec2[diff.cpp17.decl]{\ref{dcl.decl}: declarators}
1939-
1940-
\diffref{dcl.fct}
1941+
\diffrefs{class.ctor}{class.dtor}
19411942
\change
1942-
The class name can no longer be used parenthesized
1943-
in an explicit constructor declaration.
1944-
The \grammarterm{conversion-function-id} can no longer be used parenthesized
1945-
in an explicit conversion function declaration.
1943+
A \grammarterm{simple-template-id}
1944+
is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor.
19461945
\rationale
1947-
Necessary for new functionality.
1946+
Remove potentially error-prone option for redundancy.
19481947
\effect
19491948
Valid \CppXVII{} code may fail to compile
19501949
in this International Standard. For example:
19511950
\begin{codeblock}
1952-
struct S {
1953-
explicit (S)(const S&); // ill-formed; previously well-formed
1954-
explicit (operator int)(); // ill-formed; previously well-formed
1951+
template<class T>
1952+
struct A {
1953+
A<T>(); // error: \grammarterm{simple-template-id} not allowed for constructor
1954+
A(int); // OK, \grammarterm{injected-class-name} used
1955+
~A<T>(); // error: \grammarterm{simple-template-id} not allowed for destructor
19551956
};
19561957
\end{codeblock}
19571958

0 commit comments

Comments
 (0)