Skip to content

Commit c40de80

Browse files
authored
Merge 2022-11 CWG Motion 10
P2706R0 Redundant specification for defaulted functions
2 parents fa07eb4 + 7af27af commit c40de80

File tree

2 files changed

+11
-49
lines changed

2 files changed

+11
-49
lines changed

source/classes.tex

Lines changed: 5 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,8 +1040,7 @@
10401040
The implementation will implicitly declare these member functions for some class
10411041
types when the program does not explicitly declare them.
10421042
The implementation will implicitly define them
1043-
if they are odr-used\iref{term.odr.use} or
1044-
needed for constant evaluation\iref{expr.const}.
1043+
as needed\iref{dcl.fct.def.default}.
10451044
\end{note}
10461045
An implicitly-declared special member function is declared at the closing
10471046
\tcode{\}} of the \grammarterm{class-specifier}.
@@ -1303,15 +1302,7 @@
13031302
\defnx{non-trivial}{constructor!default!non-trivial}.
13041303

13051304
\pnum
1306-
A default constructor
1307-
that is defaulted and not defined as deleted
1308-
is
1309-
\defnx{implicitly defined}{constructor!implicitly defined}
1310-
when it is odr-used\iref{term.odr.use}
1311-
to initialize an object of its class type\iref{intro.object},
1312-
when it is needed for constant evaluation\iref{expr.const}, or
1313-
when it is explicitly defaulted after its first declaration.
1314-
The implicitly-defined default constructor performs the set of
1305+
An implicitly-defined\iref{dcl.fct.def.default} default constructor performs the set of
13151306
initializations of the class that would be performed by a user-written default
13161307
constructor for that class with no
13171308
\grammarterm{ctor-initializer}\iref{class.base.init} and an empty
@@ -1602,20 +1593,11 @@
16021593
\defnx{non-trivial}{constructor!copy!nontrivial}.
16031594

16041595
\pnum
1605-
\indextext{constructor!copy!implicitly defined}%
1606-
\indextext{constructor!move!implicitly defined}%
1607-
A copy/move constructor
1608-
that is defaulted and not defined as deleted
1609-
is
1610-
\term{implicitly defined}
1611-
when it is odr-used\iref{term.odr.use},
1612-
when it is needed for constant evaluation\iref{expr.const}, or
1613-
when it is explicitly defaulted after its first declaration.
16141596
\begin{note}
16151597
The copy/move constructor is implicitly defined even if the implementation elided
16161598
its odr-use\iref{term.odr.use,class.temporary}.
16171599
\end{note}
1618-
If the implicitly-defined constructor would satisfy the requirements of a
1600+
If an implicitly-defined\iref{dcl.fct.def.default} constructor would satisfy the requirements of a
16191601
constexpr function\iref{dcl.constexpr}, the implicitly-defined
16201602
constructor is \keyword{constexpr}.
16211603

@@ -1905,18 +1887,7 @@
19051887
\defnx{non-trivial}{assignment operator!copy!non-trivial}.
19061888

19071889
\pnum
1908-
\indextext{assignment operator!copy!implicitly defined}%
1909-
\indextext{assignment operator!move!implicitly defined}%
1910-
A copy/move assignment operator for a class \tcode{X}
1911-
that is defaulted and not defined as deleted
1912-
is
1913-
\term{implicitly defined}
1914-
when it is odr-used\iref{term.odr.use}
1915-
(e.g., when it is selected by overload resolution
1916-
to assign to an object of its class type),
1917-
when it is needed for constant evaluation\iref{expr.const}, or
1918-
when it is explicitly defaulted after its first declaration.
1919-
The implicitly-defined copy/move assignment operator is \keyword{constexpr}.
1890+
An implicitly-defined\iref{dcl.fct.def.default} copy/move assignment operator is \keyword{constexpr}.
19201891

19211892
\pnum
19221893
Before the defaulted copy/move assignment operator for a class is
@@ -2126,14 +2097,6 @@
21262097
A defaulted destructor is a constexpr destructor
21272098
if it satisfies the requirements for a constexpr function\iref{dcl.constexpr}.
21282099

2129-
\pnum
2130-
A destructor
2131-
that is defaulted and not defined as deleted
2132-
is
2133-
\defnx{implicitly defined}{destructor!implicitly defined}
2134-
when it is odr-used\iref{term.odr.use}
2135-
or when it is explicitly defaulted after its first declaration.
2136-
21372100
\pnum
21382101
Before a
21392102
defaulted destructor for a class is implicitly defined, all the non-user-provided
@@ -6435,12 +6398,7 @@
64356398
where the implicit object parameter (if any) is considered to be
64366399
the first parameter.
64376400
\end{itemize}
6438-
A comparison operator function for class \tcode{C} that
6439-
is defaulted on its first declaration and
6440-
is not defined as deleted is
6441-
\defnx{implicitly defined}{operator!comparison!implicitly defined}
6442-
when it is odr-used or needed for constant evaluation.
6443-
Name lookups in the defaulted definition
6401+
Name lookups in the implicit definition\iref{dcl.fct.def.default}
64446402
of a comparison operator function
64456403
are performed from a context equivalent to
64466404
its \grammarterm{function-body}.

source/declarations.tex

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6275,7 +6275,7 @@
62756275
Explicitly-defaulted functions and implicitly-declared functions are collectively
62766276
called \defn{defaulted} functions, and the implementation
62776277
shall provide implicit definitions
6278-
for them\iref{class.ctor,class.dtor,class.copy.ctor,class.copy.assign},
6278+
for them\iref{class.ctor,class.dtor,class.copy.ctor,class.copy.assign} as described below,
62796279
including possibly defining them as deleted.
62806280
A defaulted prospective destructor\iref{class.dtor}
62816281
that is not a destructor is defined as deleted.
@@ -6287,8 +6287,12 @@
62876287
\defn{user-provided} if it is user-declared and not explicitly
62886288
defaulted or deleted on its first declaration. A user-provided explicitly-defaulted function
62896289
(i.e., explicitly defaulted after its first declaration)
6290-
is defined at the point where it is explicitly defaulted; if such a function is implicitly
6290+
is implicitly defined at the point where it is explicitly defaulted; if such a function is implicitly
62916291
defined as deleted, the program is ill-formed.
6292+
A non-user-provided defaulted function
6293+
(i.e. implicitly declared or explicitly defaulted in the class)
6294+
that is not defined as deleted is implicitly defined when it is odr-used\iref{basic.def.odr}
6295+
or needed for constant evaluation\iref{expr.const}.
62926296
\begin{note}
62936297
Declaring a function as defaulted after its first declaration can provide
62946298
efficient execution and concise

0 commit comments

Comments
 (0)