tmp/tmpmum_nfki/{from.md → to.md}
RENAMED
|
@@ -1,15 +1,20 @@
|
|
| 1 |
### User-defined literals <a id="over.literal">[[over.literal]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
literal-operator-id:
|
| 5 |
-
'operator'
|
|
|
|
| 6 |
```
|
| 7 |
|
| 8 |
-
The *
|
| 9 |
-
|
| 10 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
|
| 12 |
A declaration whose *declarator-id* is a *literal-operator-id* shall be
|
| 13 |
a declaration of a namespace-scope function or function template (it
|
| 14 |
could be a friend function ([[class.friend]])), an explicit
|
| 15 |
instantiation or specialization of a function template, or a
|
|
@@ -32,10 +37,13 @@ const char*, std::size_t
|
|
| 32 |
const wchar_t*, std::size_t
|
| 33 |
const char16_t*, std::size_t
|
| 34 |
const char32_t*, std::size_t
|
| 35 |
```
|
| 36 |
|
|
|
|
|
|
|
|
|
|
| 37 |
A *raw literal operator* is a literal operator with a single parameter
|
| 38 |
whose type is `const char*`.
|
| 39 |
|
| 40 |
The declaration of a literal operator template shall have an empty
|
| 41 |
*parameter-declaration-clause* and its *template-parameter-list* shall
|
|
@@ -55,14 +63,17 @@ overload resolution rules. Also, they can be declared `inline` or
|
|
| 55 |
called explicitly, their addresses can be taken, etc.
|
| 56 |
|
| 57 |
``` cpp
|
| 58 |
void operator "" _km(long double); // OK
|
| 59 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 60 |
-
template <char...>
|
| 61 |
-
float operator ""
|
| 62 |
-
|
| 63 |
-
|
|
|
|
|
|
|
| 64 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 65 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 66 |
-
template <char...> int operator ""
|
|
|
|
| 67 |
```
|
| 68 |
|
|
|
|
| 1 |
### User-defined literals <a id="over.literal">[[over.literal]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
literal-operator-id:
|
| 5 |
+
'operator' string-literal identifier
|
| 6 |
+
'operator' user-defined-string-literal
|
| 7 |
```
|
| 8 |
|
| 9 |
+
The *string-literal* or *user-defined-string-literal* in a
|
| 10 |
+
*literal-operator-id* shall have no *encoding-prefix* and shall contain
|
| 11 |
+
no characters other than the implicit terminating `'\0'`. The
|
| 12 |
+
*ud-suffix* of the *user-defined-string-literal* or the *identifier* in
|
| 13 |
+
a *literal-operator-id* is called a *literal suffix identifier*. some
|
| 14 |
+
literal suffix identifiers are reserved for future standardization; see
|
| 15 |
+
[[usrlit.suffix]].
|
| 16 |
|
| 17 |
A declaration whose *declarator-id* is a *literal-operator-id* shall be
|
| 18 |
a declaration of a namespace-scope function or function template (it
|
| 19 |
could be a friend function ([[class.friend]])), an explicit
|
| 20 |
instantiation or specialization of a function template, or a
|
|
|
|
| 37 |
const wchar_t*, std::size_t
|
| 38 |
const char16_t*, std::size_t
|
| 39 |
const char32_t*, std::size_t
|
| 40 |
```
|
| 41 |
|
| 42 |
+
If a parameter has a default argument ([[dcl.fct.default]]), the
|
| 43 |
+
program is ill-formed.
|
| 44 |
+
|
| 45 |
A *raw literal operator* is a literal operator with a single parameter
|
| 46 |
whose type is `const char*`.
|
| 47 |
|
| 48 |
The declaration of a literal operator template shall have an empty
|
| 49 |
*parameter-declaration-clause* and its *template-parameter-list* shall
|
|
|
|
| 63 |
called explicitly, their addresses can be taken, etc.
|
| 64 |
|
| 65 |
``` cpp
|
| 66 |
void operator "" _km(long double); // OK
|
| 67 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 68 |
+
template <char...> double operator "" _\u03C0(); // OK: UCN for lowercase pi
|
| 69 |
+
float operator ""_e(const char*); // OK
|
| 70 |
+
float operator ""E(const char*); // error: reserved literal suffix~([usrlit.suffix], [lex.ext])
|
| 71 |
+
double operator""_Bq(long double); // OK: does not use the reserved name _Bq~([global.names])
|
| 72 |
+
double operator"" _Bq(long double); // uses the reserved name _Bq~([global.names])
|
| 73 |
+
float operator " " B(const char*); // error: non-empty string-literal
|
| 74 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 75 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 76 |
+
template <char...> int operator "" _j(const char*); // error: invalid parameter-declaration-clause
|
| 77 |
+
extern "C" void operator "" _m(long double); // error: C language linkage
|
| 78 |
```
|
| 79 |
|