tmp/tmp5da3iwut/{from.md → to.md}
RENAMED
|
@@ -49,11 +49,11 @@ The allocation and deallocation functions, `operator` `new`, `operator`
|
|
| 49 |
completely in [[basic.stc.dynamic]]. The attributes and restrictions
|
| 50 |
found in the rest of this subclause do not apply to them unless
|
| 51 |
explicitly stated in [[basic.stc.dynamic]].
|
| 52 |
|
| 53 |
An operator function shall either be a non-static member function or be
|
| 54 |
-
a non-member function
|
| 55 |
class, a reference to a class, an enumeration, or a reference to an
|
| 56 |
enumeration. It is not possible to change the precedence, grouping, or
|
| 57 |
number of operands of operators. The meaning of the operators `=`,
|
| 58 |
(unary) `&`, and `,` (comma), predefined for each type, can be changed
|
| 59 |
for specific class and enumeration types by defining operator functions
|
|
@@ -207,19 +207,19 @@ is selected as the best match function by the overload resolution
|
|
| 207 |
mechanism ([[over.match]]).
|
| 208 |
|
| 209 |
### Increment and decrement <a id="over.inc">[[over.inc]]</a>
|
| 210 |
|
| 211 |
The user-defined function called `operator++` implements the prefix and
|
| 212 |
-
postfix `++` operator. If this function is a member function
|
| 213 |
-
parameters, or a non-member function with one parameter
|
| 214 |
-
|
| 215 |
-
|
| 216 |
-
|
| 217 |
-
|
| 218 |
-
|
| 219 |
-
|
| 220 |
-
|
| 221 |
|
| 222 |
``` cpp
|
| 223 |
struct X {
|
| 224 |
X& operator++(); // prefix ++a
|
| 225 |
X operator++(int); // postfix a++
|
|
@@ -247,16 +247,21 @@ analogously.
|
|
| 247 |
|
| 248 |
### User-defined literals <a id="over.literal">[[over.literal]]</a>
|
| 249 |
|
| 250 |
``` bnf
|
| 251 |
literal-operator-id:
|
| 252 |
-
'operator'
|
|
|
|
| 253 |
```
|
| 254 |
|
| 255 |
-
The *
|
| 256 |
-
|
| 257 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 258 |
|
| 259 |
A declaration whose *declarator-id* is a *literal-operator-id* shall be
|
| 260 |
a declaration of a namespace-scope function or function template (it
|
| 261 |
could be a friend function ([[class.friend]])), an explicit
|
| 262 |
instantiation or specialization of a function template, or a
|
|
@@ -279,10 +284,13 @@ const char*, std::size_t
|
|
| 279 |
const wchar_t*, std::size_t
|
| 280 |
const char16_t*, std::size_t
|
| 281 |
const char32_t*, std::size_t
|
| 282 |
```
|
| 283 |
|
|
|
|
|
|
|
|
|
|
| 284 |
A *raw literal operator* is a literal operator with a single parameter
|
| 285 |
whose type is `const char*`.
|
| 286 |
|
| 287 |
The declaration of a literal operator template shall have an empty
|
| 288 |
*parameter-declaration-clause* and its *template-parameter-list* shall
|
|
@@ -302,14 +310,17 @@ overload resolution rules. Also, they can be declared `inline` or
|
|
| 302 |
called explicitly, their addresses can be taken, etc.
|
| 303 |
|
| 304 |
``` cpp
|
| 305 |
void operator "" _km(long double); // OK
|
| 306 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 307 |
-
template <char...>
|
| 308 |
-
float operator ""
|
| 309 |
-
|
| 310 |
-
|
|
|
|
|
|
|
| 311 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 312 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 313 |
-
template <char...> int operator ""
|
|
|
|
| 314 |
```
|
| 315 |
|
|
|
|
| 49 |
completely in [[basic.stc.dynamic]]. The attributes and restrictions
|
| 50 |
found in the rest of this subclause do not apply to them unless
|
| 51 |
explicitly stated in [[basic.stc.dynamic]].
|
| 52 |
|
| 53 |
An operator function shall either be a non-static member function or be
|
| 54 |
+
a non-member function that has at least one parameter whose type is a
|
| 55 |
class, a reference to a class, an enumeration, or a reference to an
|
| 56 |
enumeration. It is not possible to change the precedence, grouping, or
|
| 57 |
number of operands of operators. The meaning of the operators `=`,
|
| 58 |
(unary) `&`, and `,` (comma), predefined for each type, can be changed
|
| 59 |
for specific class and enumeration types by defining operator functions
|
|
|
|
| 207 |
mechanism ([[over.match]]).
|
| 208 |
|
| 209 |
### Increment and decrement <a id="over.inc">[[over.inc]]</a>
|
| 210 |
|
| 211 |
The user-defined function called `operator++` implements the prefix and
|
| 212 |
+
postfix `++` operator. If this function is a non-static member function
|
| 213 |
+
with no parameters, or a non-member function with one parameter, it
|
| 214 |
+
defines the prefix increment operator `++` for objects of that type. If
|
| 215 |
+
the function is a non-static member function with one parameter (which
|
| 216 |
+
shall be of type `int`) or a non-member function with two parameters
|
| 217 |
+
(the second of which shall be of type `int`), it defines the postfix
|
| 218 |
+
increment operator `++` for objects of that type. When the postfix
|
| 219 |
+
increment is called as a result of using the `++` operator, the `int`
|
| 220 |
+
argument will have value zero.[^13]
|
| 221 |
|
| 222 |
``` cpp
|
| 223 |
struct X {
|
| 224 |
X& operator++(); // prefix ++a
|
| 225 |
X operator++(int); // postfix a++
|
|
|
|
| 247 |
|
| 248 |
### User-defined literals <a id="over.literal">[[over.literal]]</a>
|
| 249 |
|
| 250 |
``` bnf
|
| 251 |
literal-operator-id:
|
| 252 |
+
'operator' string-literal identifier
|
| 253 |
+
'operator' user-defined-string-literal
|
| 254 |
```
|
| 255 |
|
| 256 |
+
The *string-literal* or *user-defined-string-literal* in a
|
| 257 |
+
*literal-operator-id* shall have no *encoding-prefix* and shall contain
|
| 258 |
+
no characters other than the implicit terminating `'\0'`. The
|
| 259 |
+
*ud-suffix* of the *user-defined-string-literal* or the *identifier* in
|
| 260 |
+
a *literal-operator-id* is called a *literal suffix identifier*. some
|
| 261 |
+
literal suffix identifiers are reserved for future standardization; see
|
| 262 |
+
[[usrlit.suffix]].
|
| 263 |
|
| 264 |
A declaration whose *declarator-id* is a *literal-operator-id* shall be
|
| 265 |
a declaration of a namespace-scope function or function template (it
|
| 266 |
could be a friend function ([[class.friend]])), an explicit
|
| 267 |
instantiation or specialization of a function template, or a
|
|
|
|
| 284 |
const wchar_t*, std::size_t
|
| 285 |
const char16_t*, std::size_t
|
| 286 |
const char32_t*, std::size_t
|
| 287 |
```
|
| 288 |
|
| 289 |
+
If a parameter has a default argument ([[dcl.fct.default]]), the
|
| 290 |
+
program is ill-formed.
|
| 291 |
+
|
| 292 |
A *raw literal operator* is a literal operator with a single parameter
|
| 293 |
whose type is `const char*`.
|
| 294 |
|
| 295 |
The declaration of a literal operator template shall have an empty
|
| 296 |
*parameter-declaration-clause* and its *template-parameter-list* shall
|
|
|
|
| 310 |
called explicitly, their addresses can be taken, etc.
|
| 311 |
|
| 312 |
``` cpp
|
| 313 |
void operator "" _km(long double); // OK
|
| 314 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 315 |
+
template <char...> double operator "" _\u03C0(); // OK: UCN for lowercase pi
|
| 316 |
+
float operator ""_e(const char*); // OK
|
| 317 |
+
float operator ""E(const char*); // error: reserved literal suffix~([usrlit.suffix], [lex.ext])
|
| 318 |
+
double operator""_Bq(long double); // OK: does not use the reserved name _Bq~([global.names])
|
| 319 |
+
double operator"" _Bq(long double); // uses the reserved name _Bq~([global.names])
|
| 320 |
+
float operator " " B(const char*); // error: non-empty string-literal
|
| 321 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 322 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 323 |
+
template <char...> int operator "" _j(const char*); // error: invalid parameter-declaration-clause
|
| 324 |
+
extern "C" void operator "" _m(long double); // error: C language linkage
|
| 325 |
```
|
| 326 |
|