From Jason Turner

[dcl.fct.def]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmp2nr_t1c1/{from.md → to.md} +26 -25
tmp/tmp2nr_t1c1/{from.md → to.md} RENAMED
@@ -62,22 +62,22 @@ void print(int a, int) {
62
  }
63
  ```
64
 
65
  In the *function-body*, a *function-local predefined variable* denotes a
66
  block-scope object of static storage duration that is implicitly defined
67
- (see  [[basic.scope.local]]).
68
 
69
  The function-local predefined variable `__func__` is defined as if a
70
  definition of the form
71
 
72
  ``` cpp
73
  static const char __func__[] = "function-name";
74
  ```
75
 
76
  had been provided, where *function-name* is an *implementation-defined*
77
  string. It is unspecified whether such a variable has an address
78
- distinct from that of any other object in the program.[^14]
79
 
80
  ``` cpp
81
  struct S {
82
  S() : s(__func__) { } // OK
83
  const char* s;
@@ -88,11 +88,11 @@ void f(const char * s = __func__); // error: __func__ is undeclared
88
  ### Explicitly-defaulted functions <a id="dcl.fct.def.default">[[dcl.fct.def.default]]</a>
89
 
90
  A function definition of the form:
91
 
92
  ``` bnf
93
- attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ declarator ' = default ;'
94
  ```
95
 
96
  is called an *explicitly-defaulted* definition. A function that is
97
  explicitly defaulted shall
98
 
@@ -103,50 +103,51 @@ explicitly defaulted shall
103
  non-const `T`”, where `T` is the name of the member function’s class)
104
  as if it had been implicitly declared, and
105
  - not have default arguments.
106
 
107
  An explicitly-defaulted function may be declared `constexpr` only if it
108
- would have been implicitly declared as `constexpr`, and may have an
109
- explicit *exception-specification* only if it is compatible (
110
- [[except.spec]]) with the *exception-specification* on the implicit
111
- declaration. If a function is explicitly defaulted on its first
112
- declaration,
113
 
114
  - it is implicitly considered to be `constexpr` if the implicit
115
- declaration would be,
116
  - it is implicitly considered to have the same *exception-specification*
117
- as if it had been implicitly declared ([[except.spec]]), and
118
- - in the case of a copy constructor, move constructor, copy assignment
119
- operator, or move assignment operator, it shall have the same
120
- parameter type as if it had been implicitly declared.
 
 
 
 
 
121
 
122
  ``` cpp
123
  struct S {
124
  constexpr S() = default; // ill-formed: implicit S() is not constexpr
125
  S(int a = 0) = default; // ill-formed: default argument
126
  void operator=(const S&) = default; // ill-formed: non-matching return type
127
- ~S() throw(int) = default; // ill-formed: exception specification does not match
128
  private:
129
  int i;
130
  S(S&); // OK: private copy constructor
131
  };
132
  S::S(S&) = default; // OK: defines copy constructor
133
  ```
134
 
135
  Explicitly-defaulted functions and implicitly-declared functions are
136
  collectively called *defaulted* functions, and the implementation shall
137
  provide implicit definitions for them ([[class.ctor]] [[class.dtor]],
138
- [[class.copy]]), which might mean defining them as deleted. A special
139
- member function is *user-provided* if it is user-declared and not
140
- explicitly defaulted or deleted on its first declaration. A
141
- user-provided explicitly-defaulted function (i.e., explicitly defaulted
142
- after its first declaration) is defined at the point where it is
143
- explicitly defaulted; if such a function is implicitly defined as
144
- deleted, the program is ill-formed. Declaring a function as defaulted
145
- after its first declaration can provide efficient execution and concise
146
- definition while enabling a stable binary interface to an evolving code
147
- base.
148
 
149
  ``` cpp
150
  struct trivial {
151
  trivial() = default;
152
  trivial(const trivial&) = default;
@@ -165,11 +166,11 @@ nontrivial1::nontrivial1() = default; // not first declaration
165
  ### Deleted definitions <a id="dcl.fct.def.delete">[[dcl.fct.def.delete]]</a>
166
 
167
  A function definition of the form:
168
 
169
  ``` bnf
170
- attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ declarator ' = delete ;'
171
  ```
172
 
173
  is called a *deleted definition*. A function with a deleted definition
174
  is also called a *deleted function*.
175
 
 
62
  }
63
  ```
64
 
65
  In the *function-body*, a *function-local predefined variable* denotes a
66
  block-scope object of static storage duration that is implicitly defined
67
+ (see  [[basic.scope.block]]).
68
 
69
  The function-local predefined variable `__func__` is defined as if a
70
  definition of the form
71
 
72
  ``` cpp
73
  static const char __func__[] = "function-name";
74
  ```
75
 
76
  had been provided, where *function-name* is an *implementation-defined*
77
  string. It is unspecified whether such a variable has an address
78
+ distinct from that of any other object in the program.[^13]
79
 
80
  ``` cpp
81
  struct S {
82
  S() : s(__func__) { } // OK
83
  const char* s;
 
88
  ### Explicitly-defaulted functions <a id="dcl.fct.def.default">[[dcl.fct.def.default]]</a>
89
 
90
  A function definition of the form:
91
 
92
  ``` bnf
93
+ attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ declarator virt-specifier-seqₒₚₜ ' = default ;'
94
  ```
95
 
96
  is called an *explicitly-defaulted* definition. A function that is
97
  explicitly defaulted shall
98
 
 
103
  non-const `T`”, where `T` is the name of the member function’s class)
104
  as if it had been implicitly declared, and
105
  - not have default arguments.
106
 
107
  An explicitly-defaulted function may be declared `constexpr` only if it
108
+ would have been implicitly declared as `constexpr`. If a function is
109
+ explicitly defaulted on its first declaration,
 
 
 
110
 
111
  - it is implicitly considered to be `constexpr` if the implicit
112
+ declaration would be, and,
113
  - it is implicitly considered to have the same *exception-specification*
114
+ as if it had been implicitly declared ([[except.spec]]).
115
+
116
+ If a function that is explicitly defaulted has an explicit
117
+ *exception-specification* that is not compatible ([[except.spec]]) with
118
+ the *exception-specification* on the implicit declaration, then
119
+
120
+ - if the function is explicitly defaulted on its first declaration, it
121
+ is defined as deleted;
122
+ - otherwise, the program is ill-formed.
123
 
124
  ``` cpp
125
  struct S {
126
  constexpr S() = default; // ill-formed: implicit S() is not constexpr
127
  S(int a = 0) = default; // ill-formed: default argument
128
  void operator=(const S&) = default; // ill-formed: non-matching return type
129
+ ~S() throw(int) = default; // deleted: exception specification does not match
130
  private:
131
  int i;
132
  S(S&); // OK: private copy constructor
133
  };
134
  S::S(S&) = default; // OK: defines copy constructor
135
  ```
136
 
137
  Explicitly-defaulted functions and implicitly-declared functions are
138
  collectively called *defaulted* functions, and the implementation shall
139
  provide implicit definitions for them ([[class.ctor]] [[class.dtor]],
140
+ [[class.copy]]), which might mean defining them as deleted. A function
141
+ is *user-provided* if it is user-declared and not explicitly defaulted
142
+ or deleted on its first declaration. A user-provided
143
+ explicitly-defaulted function (i.e., explicitly defaulted after its
144
+ first declaration) is defined at the point where it is explicitly
145
+ defaulted; if such a function is implicitly defined as deleted, the
146
+ program is ill-formed. Declaring a function as defaulted after its first
147
+ declaration can provide efficient execution and concise definition while
148
+ enabling a stable binary interface to an evolving code base.
 
149
 
150
  ``` cpp
151
  struct trivial {
152
  trivial() = default;
153
  trivial(const trivial&) = default;
 
166
  ### Deleted definitions <a id="dcl.fct.def.delete">[[dcl.fct.def.delete]]</a>
167
 
168
  A function definition of the form:
169
 
170
  ``` bnf
171
+ attribute-specifier-seqₒₚₜ decl-specifier-seqₒₚₜ declarator virt-specifier-seqₒₚₜ ' = delete ;'
172
  ```
173
 
174
  is called a *deleted definition*. A function with a deleted definition
175
  is also called a *deleted function*.
176