tmp/tmpe6jdt1vj/{from.md → to.md}
RENAMED
|
@@ -8,13 +8,14 @@ literal-operator-id:
|
|
| 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*.
|
| 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
|
|
@@ -51,29 +52,34 @@ have a single *template-parameter* that is a non-type template parameter
|
|
| 51 |
pack ([[temp.variadic]]) with element type `char`.
|
| 52 |
|
| 53 |
Literal operators and literal operator templates shall not have C
|
| 54 |
language linkage.
|
| 55 |
|
| 56 |
-
Literal operators and literal operator templates are usually
|
| 57 |
-
implicitly through user-defined literals ([[lex.ext]]).
|
| 58 |
-
for the constraints described above, they are ordinary
|
| 59 |
-
functions and function templates. In particular, they
|
| 60 |
-
ordinary functions and function templates and they
|
| 61 |
-
overload resolution rules. Also, they can be declared
|
| 62 |
-
`constexpr`, they may have internal or external linkage,
|
| 63 |
-
called explicitly, their addresses can be taken,
|
|
|
|
|
|
|
|
|
|
| 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
|
| 72 |
-
double operator"" _Bq(long double); // uses the reserved
|
| 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 |
|
|
|
|
|
|
|
|
|
| 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]]. A declaration whose *literal-operator-id* uses such a
|
| 16 |
+
literal suffix identifier is ill-formed, no diagnostic required.
|
| 17 |
|
| 18 |
A declaration whose *declarator-id* is a *literal-operator-id* shall be
|
| 19 |
a declaration of a namespace-scope function or function template (it
|
| 20 |
could be a friend function ([[class.friend]])), an explicit
|
| 21 |
instantiation or specialization of a function template, or a
|
|
|
|
| 52 |
pack ([[temp.variadic]]) with element type `char`.
|
| 53 |
|
| 54 |
Literal operators and literal operator templates shall not have C
|
| 55 |
language linkage.
|
| 56 |
|
| 57 |
+
[*Note 1*: Literal operators and literal operator templates are usually
|
| 58 |
+
invoked implicitly through user-defined literals ([[lex.ext]]).
|
| 59 |
+
However, except for the constraints described above, they are ordinary
|
| 60 |
+
namespace-scope functions and function templates. In particular, they
|
| 61 |
+
are looked up like ordinary functions and function templates and they
|
| 62 |
+
follow the same overload resolution rules. Also, they can be declared
|
| 63 |
+
`inline` or `constexpr`, they may have internal or external linkage,
|
| 64 |
+
they can be called explicitly, their addresses can be taken,
|
| 65 |
+
etc. — *end note*]
|
| 66 |
+
|
| 67 |
+
[*Example 1*:
|
| 68 |
|
| 69 |
``` cpp
|
| 70 |
void operator "" _km(long double); // OK
|
| 71 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 72 |
template <char...> double operator "" _\u03C0(); // OK: UCN for lowercase pi
|
| 73 |
float operator ""_e(const char*); // OK
|
| 74 |
float operator ""E(const char*); // error: reserved literal suffix~([usrlit.suffix], [lex.ext])
|
| 75 |
+
double operator""_Bq(long double); // OK: does not use the reserved identifier _Bq~([lex.name])
|
| 76 |
+
double operator"" _Bq(long double); // uses the reserved identifier _Bq~([lex.name])
|
| 77 |
float operator " " B(const char*); // error: non-empty string-literal
|
| 78 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 79 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 80 |
template <char...> int operator "" _j(const char*); // error: invalid parameter-declaration-clause
|
| 81 |
extern "C" void operator "" _m(long double); // error: C language linkage
|
| 82 |
```
|
| 83 |
|
| 84 |
+
— *end example*]
|
| 85 |
+
|