Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 14a4f80

Browse filesBrowse files
committed
[stmt.return,class.{ctor,dtor}] Clarify no return operand
Highlight that constructors and destructors do not have a return type and thus a return statement within a constructor or destructor cannot have an operand.
1 parent 3c19e31 commit 14a4f80
Copy full SHA for 14a4f80

File tree

Expand file treeCollapse file tree

2 files changed

+16
-7
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+16
-7
lines changed

‎source/classes.tex

Copy file name to clipboardExpand all lines: source/classes.tex
+11-5Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,13 @@
12081208
most derived object\iref{intro.object} ends.
12091209

12101210
\pnum
1211-
\indextext{restriction!constructor}%
1212-
A
1213-
\tcode{return}
1214-
statement in the body of a constructor shall not specify a return value.
12151211
\indextext{constructor!address of}%
12161212
The address of a constructor shall not be taken.
1213+
\indextext{restriction!constructor}%
1214+
\begin{note}
1215+
A \tcode{return} statement in the body of a constructor
1216+
cannot specify a return value\iref{stmt.return}.
1217+
\end{note}
12171218

12181219
\pnum
12191220
A constructor shall not be a coroutine.
@@ -2078,8 +2079,13 @@
20782079
the selected destructor may be deleted\iref{dcl.fct.def.delete}.
20792080

20802081
\pnum
2081-
\indextext{restriction!destructor}%
2082+
\indextext{destructor!address of}%
20822083
The address of a destructor shall not be taken.
2084+
\indextext{restriction!destructor}%
2085+
\begin{note}
2086+
A \tcode{return} statement in the body of a destructor
2087+
cannot specify a return value\iref{stmt.return}.
2088+
\end{note}
20832089
\indextext{\idxcode{const}!destructor and}%
20842090
\indextext{\idxcode{volatile}!destructor and}%
20852091
A destructor can be invoked for a

‎source/statements.tex

Copy file name to clipboardExpand all lines: source/statements.tex
+5-2Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -811,15 +811,18 @@
811811
\indextext{\idxcode{return}!constructor and}%
812812
\indextext{\idxcode{return}!constructor and}%
813813
A \tcode{return} statement with an operand of type \keyword{void} shall be used only
814-
in a function whose return type is \cv{}~\keyword{void}.
814+
in a function that has a \cv{}~\keyword{void} return type.
815815
A \tcode{return} statement with any other operand shall be used only
816-
in a function whose return type is not \cv{}~\keyword{void};
816+
in a function that has a return type other than \cv{}~\keyword{void};
817817
\indextext{conversion!return type}%
818818
the \tcode{return} statement initializes the
819819
returned reference or prvalue result object
820820
of the (explicit or implicit) function call
821821
by copy-initialization\iref{dcl.init} from the operand.
822822
\begin{note}
823+
A constructor or destructor does not have a return type.
824+
\end{note}
825+
\begin{note}
823826
A \tcode{return} statement can involve
824827
an invocation of a constructor to perform a copy or move of the operand
825828
if it is not a prvalue or if its type differs from the return type of the function.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.