From Jason Turner

[dcl.fct.def.default]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpr19r2x00/{from.md → to.md} +19 -12
tmp/tmpr19r2x00/{from.md → to.md} RENAMED
@@ -2,24 +2,24 @@
2
 
3
  A function definition whose *function-body* is of the form `= default ;`
4
  is called an *explicitly-defaulted* definition. A function that is
5
  explicitly defaulted shall
6
 
7
- - be a special member function or a comparison operator function
8
- [[over.binary]], and
9
- - not have default arguments.
10
 
11
  An explicitly defaulted special member function `F₁` is allowed to
12
  differ from the corresponding special member function `F₂` that would
13
  have been implicitly declared, as follows:
14
 
15
  - `F₁` and `F₂` may have differing *ref-qualifier*s;
16
  - if `F₂` has an implicit object parameter of type “reference to `C`”,
17
  `F₁` may be an explicit object member function whose explicit object
18
- parameter is of type “reference to `C`”, in which case the type of
19
- `F₁` would differ from the type of `F₂` in that the type of `F₁` has
20
- an additional parameter;
21
  - `F₁` and `F₂` may have differing exception specifications; and
22
  - if `F₂` has a non-object parameter of type `const C&`, the
23
  corresponding non-object parameter of `F₁` may be of type `C&`.
24
 
25
  If the type of `F₁` differs from the type of `F₂` in a way other than as
@@ -34,10 +34,13 @@ allowed by the preceding rules, then:
34
 
35
  A function explicitly defaulted on its first declaration is implicitly
36
  inline [[dcl.inline]], and is implicitly constexpr [[dcl.constexpr]] if
37
  it is constexpr-suitable.
38
 
 
 
 
39
  [*Example 1*:
40
 
41
  ``` cpp
42
  struct S {
43
  S(int a = 0) = default; // error: default argument
@@ -75,21 +78,25 @@ neither a prospective destructor nor an eligible special member function
75
  [[special]] is defined as deleted. A function is *user-provided* if it
76
  is user-declared and not explicitly defaulted or deleted on its first
77
  declaration. A user-provided explicitly-defaulted function (i.e.,
78
  explicitly defaulted after its first declaration) is implicitly defined
79
  at the point where it is explicitly defaulted; if such a function is
80
- implicitly defined as deleted, the program is ill-formed. A
81
- non-user-provided defaulted function (i.e., implicitly declared or
82
- explicitly defaulted in the class) that is not defined as deleted is
83
- implicitly defined when it is odr-used [[basic.def.odr]] or needed for
84
- constant evaluation [[expr.const]].
85
 
86
- [*Note 1*: Declaring a function as defaulted after its first
87
  declaration can provide efficient execution and concise definition while
88
  enabling a stable binary interface to an evolving code
89
  base. — *end note*]
90
 
 
 
 
 
 
 
 
 
91
  [*Example 2*:
92
 
93
  ``` cpp
94
  struct trivial {
95
  trivial() = default;
 
2
 
3
  A function definition whose *function-body* is of the form `= default ;`
4
  is called an *explicitly-defaulted* definition. A function that is
5
  explicitly defaulted shall
6
 
7
+ - be a special member function [[special]] or a comparison operator
8
+ function [[over.binary]], [[class.compare.default]], and
9
+ - not have default arguments [[dcl.fct.default]].
10
 
11
  An explicitly defaulted special member function `F₁` is allowed to
12
  differ from the corresponding special member function `F₂` that would
13
  have been implicitly declared, as follows:
14
 
15
  - `F₁` and `F₂` may have differing *ref-qualifier*s;
16
  - if `F₂` has an implicit object parameter of type “reference to `C`”,
17
  `F₁` may be an explicit object member function whose explicit object
18
+ parameter is of (possibly different) type “reference to `C`”, in which
19
+ case the type of `F₁` would differ from the type of `F₂` in that the
20
+ type of `F₁` has an additional parameter;
21
  - `F₁` and `F₂` may have differing exception specifications; and
22
  - if `F₂` has a non-object parameter of type `const C&`, the
23
  corresponding non-object parameter of `F₁` may be of type `C&`.
24
 
25
  If the type of `F₁` differs from the type of `F₂` in a way other than as
 
34
 
35
  A function explicitly defaulted on its first declaration is implicitly
36
  inline [[dcl.inline]], and is implicitly constexpr [[dcl.constexpr]] if
37
  it is constexpr-suitable.
38
 
39
+ [*Note 1*: Other defaulted functions are not implicitly
40
+ constexpr. — *end note*]
41
+
42
  [*Example 1*:
43
 
44
  ``` cpp
45
  struct S {
46
  S(int a = 0) = default; // error: default argument
 
78
  [[special]] is defined as deleted. A function is *user-provided* if it
79
  is user-declared and not explicitly defaulted or deleted on its first
80
  declaration. A user-provided explicitly-defaulted function (i.e.,
81
  explicitly defaulted after its first declaration) is implicitly defined
82
  at the point where it is explicitly defaulted; if such a function is
83
+ implicitly defined as deleted, the program is ill-formed.
 
 
 
 
84
 
85
+ [*Note 2*: Declaring a function as defaulted after its first
86
  declaration can provide efficient execution and concise definition while
87
  enabling a stable binary interface to an evolving code
88
  base. — *end note*]
89
 
90
+ A non-user-provided defaulted function (i.e., implicitly declared or
91
+ explicitly defaulted in the class) that is not defined as deleted is
92
+ implicitly defined when it is odr-used [[basic.def.odr]] or needed for
93
+ constant evaluation [[expr.const]].
94
+
95
+ [*Note 3*: The implicit definition of a non-user-provided defaulted
96
+ function does not bind any names. — *end note*]
97
+
98
  [*Example 2*:
99
 
100
  ``` cpp
101
  struct trivial {
102
  trivial() = default;