Skip to content

Commit f52dc60

Browse files
author
Dawn Perchik
committed
CWG2237 Can a template-id name a constructor?
1 parent d2a83a9 commit f52dc60

File tree

3 files changed

+27
-18
lines changed

3 files changed

+27
-18
lines changed

source/compatibility.tex

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1863,6 +1863,26 @@
18631863
if those entities are only referenced in contexts
18641864
that do not result in an odr-use.
18651865

1866+
\rSec2[diff.cpp17.special]{\ref{special}: special member functions}
1867+
1868+
\diffrefs{class.ctor}{class.dtor}
1869+
\change
1870+
A \grammarterm{simple-template-id}
1871+
is no longer valid as the \grammarterm{declarator-id} of a constructor or destructor.
1872+
\rationale
1873+
Remove potentially error-prone option for redundancy.
1874+
\effect
1875+
Valid \CppXVII{} code may fail to compile
1876+
in this International Standard. For example:
1877+
\begin{codeblock}
1878+
template<class T>
1879+
struct A {
1880+
A<T>(); // error: \grammarterm{simple-template-id} not allowed for constructor
1881+
A(int); // OK, \grammarterm{injected-class-name} used
1882+
~A<T>(); // error: \grammarterm{simple-template-id} not allowed for destructor
1883+
};
1884+
\end{codeblock}
1885+
18661886
\rSec2[diff.cpp17.temp]{\ref{temp}: templates}
18671887

18681888
\diffref{temp.names}

source/macros.tex

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@
318318
%% Change descriptions
319319
\newcommand{\diffdef}[1]{\hfill\break\textbf{#1:}\space}
320320
\newcommand{\diffref}[1]{\pnum\textbf{Affected subclause:} \ref{#1}}
321+
\newcommand{\diffrefs}[2]{\pnum\textbf{Affected subclauses:} \ref{#1}, \ref{#2}}
321322
\newcommand{\change}{\diffdef{Change}}
322323
\newcommand{\rationale}{\diffdef{Rationale}}
323324
\newcommand{\effect}{\diffdef{Effect on original feature}}

source/special.tex

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,10 @@
8989
\begin{itemize}
9090
\item
9191
in a \grammarterm{member-declaration} that belongs to the
92-
\grammarterm{member-specification} of a class but is not a friend
92+
\grammarterm{member-specification} of a class or class template
93+
but is not a friend
9394
declaration\iref{class.friend}, the \grammarterm{id-expression} is the
94-
injected-class-name\iref{class} of the immediately-enclosing class;
95-
96-
\item
97-
in a \grammarterm{member-declaration} that belongs to the
98-
\grammarterm{member-specification} of a class template but is not a friend
99-
declaration, the \grammarterm{id-expression} is a \grammarterm{class-name} that
100-
names the current instantiation\iref{temp.dep.type} of the
101-
immediately-enclosing class template; or
95+
injected-class-name\iref{class} of the immediately-enclosing entity or
10296

10397
\item
10498
in a declaration at namespace scope or in a friend declaration, the
@@ -1023,17 +1017,11 @@
10231017
\begin{itemize}
10241018
\item
10251019
in a \grammarterm{member-declaration} that belongs to the
1026-
\grammarterm{member-specification} of a class but is not a friend
1020+
\grammarterm{member-specification} of a class or class template
1021+
but is not a friend
10271022
declaration\iref{class.friend}, the \grammarterm{id-expression} is
10281023
\tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} is the
1029-
injected-class-name\iref{class} of the immediately-enclosing class;
1030-
1031-
\item
1032-
in a \grammarterm{member-declaration} that belongs to the
1033-
\grammarterm{member-specification} of a class template but is not a friend
1034-
declaration, the \grammarterm{id-expression} is
1035-
\tcode{\~}\grammarterm{class-name} and the \grammarterm{class-name} names the
1036-
current instantiation\iref{temp.dep.type} of the immediately-enclosing class template; or
1024+
injected-class-name\iref{class} of the immediately-enclosing entity or
10371025

10381026
\item
10391027
in a declaration at namespace scope or in a friend declaration, the

0 commit comments

Comments
 (0)