tmp/tmpx2hovdoy/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
### User-defined literals <a id="lex.ext">[[lex.ext]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
user-defined-literal:
|
| 5 |
user-defined-integer-literal
|
| 6 |
-
user-defined-floating-literal
|
| 7 |
user-defined-string-literal
|
| 8 |
user-defined-character-literal
|
| 9 |
```
|
| 10 |
|
| 11 |
``` bnf
|
|
@@ -15,11 +15,11 @@ user-defined-integer-literal:
|
|
| 15 |
hexadecimal-literal ud-suffix
|
| 16 |
binary-literal ud-suffix
|
| 17 |
```
|
| 18 |
|
| 19 |
``` bnf
|
| 20 |
-
user-defined-floating-literal:
|
| 21 |
fractional-constant exponent-partₒₚₜ ud-suffix
|
| 22 |
digit-sequence exponent-part ud-suffix
|
| 23 |
hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part ud-suffix
|
| 24 |
hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part ud-suffix
|
| 25 |
```
|
|
@@ -53,65 +53,65 @@ is a *user-defined-literal*, but `12LL` is an *integer-literal*.
|
|
| 53 |
The syntactic non-terminal preceding the *ud-suffix* in a
|
| 54 |
*user-defined-literal* is taken to be the longest sequence of characters
|
| 55 |
that could match that non-terminal.
|
| 56 |
|
| 57 |
A *user-defined-literal* is treated as a call to a literal operator or
|
| 58 |
-
literal operator template
|
| 59 |
this call for a given *user-defined-literal* *L* with *ud-suffix* *X*,
|
| 60 |
the *literal-operator-id* whose literal suffix identifier is *X* is
|
| 61 |
looked up in the context of *L* using the rules for unqualified name
|
| 62 |
-
lookup
|
| 63 |
-
|
| 64 |
|
| 65 |
If *L* is a *user-defined-integer-literal*, let *n* be the literal
|
| 66 |
without its *ud-suffix*. If *S* contains a literal operator with
|
| 67 |
parameter type `unsigned long long`, the literal *L* is treated as a
|
| 68 |
call of the form
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
operator "" X(nULL)
|
| 72 |
```
|
| 73 |
|
| 74 |
-
Otherwise, *S* shall contain a raw literal operator or a literal
|
| 75 |
-
operator template
|
| 76 |
-
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
operator "" X("n{"})
|
| 80 |
```
|
| 81 |
|
| 82 |
-
Otherwise (*S* contains a literal operator template), *L* is
|
| 83 |
-
a call of the form
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
operator "" X<'c₁', 'c₂', ... 'cₖ'>()
|
| 87 |
```
|
| 88 |
|
| 89 |
where *n* is the source character sequence c₁c₂...cₖ.
|
| 90 |
|
| 91 |
[*Note 1*: The sequence c₁c₂...cₖ can only contain characters from the
|
| 92 |
basic source character set. — *end note*]
|
| 93 |
|
| 94 |
-
If *L* is a *user-defined-floating-literal*, let *f* be the
|
| 95 |
-
without its *ud-suffix*. If *S* contains a literal operator with
|
| 96 |
parameter type `long double`, the literal *L* is treated as a call of
|
| 97 |
the form
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
operator "" X(fL)
|
| 101 |
```
|
| 102 |
|
| 103 |
-
Otherwise, *S* shall contain a raw literal operator or a literal
|
| 104 |
-
operator template
|
| 105 |
-
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
operator "" X("f{"})
|
| 109 |
```
|
| 110 |
|
| 111 |
-
Otherwise (*S* contains a literal operator template), *L* is
|
| 112 |
-
a call of the form
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
operator "" X<'c₁', 'c₂', ... 'cₖ'>()
|
| 116 |
```
|
| 117 |
|
|
@@ -120,20 +120,28 @@ where *f* is the source character sequence c₁c₂...cₖ.
|
|
| 120 |
[*Note 2*: The sequence c₁c₂...cₖ can only contain characters from the
|
| 121 |
basic source character set. — *end note*]
|
| 122 |
|
| 123 |
If *L* is a *user-defined-string-literal*, let *str* be the literal
|
| 124 |
without its *ud-suffix* and let *len* be the number of code units in
|
| 125 |
-
*str* (i.e., its length excluding the terminating null character).
|
|
|
|
|
|
|
| 126 |
literal *L* is treated as a call of the form
|
| 127 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
``` cpp
|
| 129 |
operator "" X(str, len)
|
| 130 |
```
|
| 131 |
|
| 132 |
If *L* is a *user-defined-character-literal*, let *ch* be the literal
|
| 133 |
-
without its *ud-suffix*. *S* shall contain a literal operator
|
| 134 |
-
[[over.literal]]
|
| 135 |
literal *L* is treated as a call of the form
|
| 136 |
|
| 137 |
``` cpp
|
| 138 |
operator "" X(ch)
|
| 139 |
```
|
|
@@ -152,16 +160,16 @@ int main() {
|
|
| 152 |
}
|
| 153 |
```
|
| 154 |
|
| 155 |
— *end example*]
|
| 156 |
|
| 157 |
-
In translation phase 6
|
| 158 |
-
concatenated and *user-defined-string-literal*s are considered
|
| 159 |
-
|
| 160 |
-
removed and ignored and the concatenation process occurs as
|
| 161 |
-
in [[lex.string]]. At the end of phase 6, if a
|
| 162 |
-
result of a concatenation involving at least one
|
| 163 |
*user-defined-string-literal*, all the participating
|
| 164 |
*user-defined-string-literal*s shall have the same *ud-suffix* and that
|
| 165 |
suffix is applied to the result of the concatenation.
|
| 166 |
|
| 167 |
[*Example 3*:
|
|
@@ -179,51 +187,55 @@ int main() {
|
|
| 179 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 180 |
[basic.link]: basic.md#basic.link
|
| 181 |
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 182 |
[basic.stc]: basic.md#basic.stc
|
| 183 |
[basic.types]: basic.md#basic.types
|
| 184 |
-
[conv.mem]:
|
| 185 |
-
[conv.ptr]:
|
| 186 |
[cpp]: cpp.md#cpp
|
| 187 |
[cpp.concat]: cpp.md#cpp.concat
|
| 188 |
[cpp.cond]: cpp.md#cpp.cond
|
|
|
|
| 189 |
[cpp.include]: cpp.md#cpp.include
|
|
|
|
| 190 |
[cpp.stringize]: cpp.md#cpp.stringize
|
| 191 |
[dcl.attr.grammar]: dcl.md#dcl.attr.grammar
|
| 192 |
[headers]: library.md#headers
|
| 193 |
[lex]: #lex
|
| 194 |
[lex.bool]: #lex.bool
|
| 195 |
[lex.ccon]: #lex.ccon
|
|
|
|
| 196 |
[lex.charset]: #lex.charset
|
| 197 |
[lex.comment]: #lex.comment
|
| 198 |
[lex.digraph]: #lex.digraph
|
| 199 |
[lex.ext]: #lex.ext
|
| 200 |
[lex.fcon]: #lex.fcon
|
|
|
|
| 201 |
[lex.header]: #lex.header
|
| 202 |
[lex.icon]: #lex.icon
|
|
|
|
|
|
|
| 203 |
[lex.key]: #lex.key
|
|
|
|
| 204 |
[lex.literal]: #lex.literal
|
| 205 |
[lex.literal.kinds]: #lex.literal.kinds
|
| 206 |
[lex.name]: #lex.name
|
|
|
|
|
|
|
|
|
|
| 207 |
[lex.nullptr]: #lex.nullptr
|
| 208 |
[lex.operators]: #lex.operators
|
| 209 |
[lex.phases]: #lex.phases
|
| 210 |
[lex.ppnumber]: #lex.ppnumber
|
| 211 |
[lex.pptoken]: #lex.pptoken
|
| 212 |
[lex.separate]: #lex.separate
|
| 213 |
[lex.string]: #lex.string
|
|
|
|
| 214 |
[lex.token]: #lex.token
|
|
|
|
|
|
|
| 215 |
[over.literal]: over.md#over.literal
|
| 216 |
-
[tab:alternative.representations]: #tab:alternative.representations
|
| 217 |
-
[tab:alternative.tokens]: #tab:alternative.tokens
|
| 218 |
-
[tab:charname.allowed]: #tab:charname.allowed
|
| 219 |
-
[tab:charname.disallowed]: #tab:charname.disallowed
|
| 220 |
-
[tab:escape.sequences]: #tab:escape.sequences
|
| 221 |
-
[tab:identifiers.special]: #tab:identifiers.special
|
| 222 |
-
[tab:keywords]: #tab:keywords
|
| 223 |
-
[tab:lex.string.concat]: #tab:lex.string.concat
|
| 224 |
-
[tab:lex.type.integer.literal]: #tab:lex.type.integer.literal
|
| 225 |
[temp.explicit]: temp.md#temp.explicit
|
| 226 |
[temp.names]: temp.md#temp.names
|
| 227 |
|
| 228 |
[^1]: Implementations must behave as if these separate phases occur,
|
| 229 |
although in practice different phases might be folded together.
|
|
@@ -244,21 +256,21 @@ int main() {
|
|
| 244 |
(described in translation phase 1) is specified as
|
| 245 |
*implementation-defined*, an implementation is required to document
|
| 246 |
how the basic source characters are represented in source files.
|
| 247 |
|
| 248 |
[^5]: A sequence of characters resembling a *universal-character-name*
|
| 249 |
-
in an *r-char-sequence*
|
| 250 |
*universal-character-name*.
|
| 251 |
|
| 252 |
[^6]: These include “digraphs” and additional reserved words. The term
|
| 253 |
“digraph” (token consisting of two characters) is not perfectly
|
| 254 |
-
descriptive, since one of the alternative preprocessing-
|
| 255 |
`%:%:` and of course several primary tokens contain two characters.
|
| 256 |
Nonetheless, those alternative tokens that aren’t lexical keywords
|
| 257 |
are colloquially known as “digraphs”.
|
| 258 |
|
| 259 |
-
[^7]: Thus the “stringized” values
|
| 260 |
will be different, maintaining the source spelling, but the tokens
|
| 261 |
can otherwise be freely interchanged.
|
| 262 |
|
| 263 |
[^8]: Literals include strings and character and numeric literals.
|
| 264 |
|
|
@@ -275,15 +287,13 @@ int main() {
|
|
| 275 |
long external identifier, but C++ does not place a translation limit
|
| 276 |
on significant characters for external identifiers. In C++, upper-
|
| 277 |
and lower-case letters are considered different for all identifiers,
|
| 278 |
including external identifiers.
|
| 279 |
|
| 280 |
-
[^11]: The term “literal” generally designates, in this
|
| 281 |
-
|
| 282 |
|
| 283 |
-
[^12]:
|
| 284 |
-
|
| 285 |
-
[^13]: They are intended for character sets where a character does not
|
| 286 |
fit into a single byte.
|
| 287 |
|
| 288 |
-
[^
|
| 289 |
compatibility with ISO C++14 and ISO C.
|
|
|
|
| 1 |
### User-defined literals <a id="lex.ext">[[lex.ext]]</a>
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
user-defined-literal:
|
| 5 |
user-defined-integer-literal
|
| 6 |
+
user-defined-floating-point-literal
|
| 7 |
user-defined-string-literal
|
| 8 |
user-defined-character-literal
|
| 9 |
```
|
| 10 |
|
| 11 |
``` bnf
|
|
|
|
| 15 |
hexadecimal-literal ud-suffix
|
| 16 |
binary-literal ud-suffix
|
| 17 |
```
|
| 18 |
|
| 19 |
``` bnf
|
| 20 |
+
user-defined-floating-point-literal:
|
| 21 |
fractional-constant exponent-partₒₚₜ ud-suffix
|
| 22 |
digit-sequence exponent-part ud-suffix
|
| 23 |
hexadecimal-prefix hexadecimal-fractional-constant binary-exponent-part ud-suffix
|
| 24 |
hexadecimal-prefix hexadecimal-digit-sequence binary-exponent-part ud-suffix
|
| 25 |
```
|
|
|
|
| 53 |
The syntactic non-terminal preceding the *ud-suffix* in a
|
| 54 |
*user-defined-literal* is taken to be the longest sequence of characters
|
| 55 |
that could match that non-terminal.
|
| 56 |
|
| 57 |
A *user-defined-literal* is treated as a call to a literal operator or
|
| 58 |
+
literal operator template [[over.literal]]. To determine the form of
|
| 59 |
this call for a given *user-defined-literal* *L* with *ud-suffix* *X*,
|
| 60 |
the *literal-operator-id* whose literal suffix identifier is *X* is
|
| 61 |
looked up in the context of *L* using the rules for unqualified name
|
| 62 |
+
lookup [[basic.lookup.unqual]]. Let *S* be the set of declarations found
|
| 63 |
+
by this lookup. *S* shall not be empty.
|
| 64 |
|
| 65 |
If *L* is a *user-defined-integer-literal*, let *n* be the literal
|
| 66 |
without its *ud-suffix*. If *S* contains a literal operator with
|
| 67 |
parameter type `unsigned long long`, the literal *L* is treated as a
|
| 68 |
call of the form
|
| 69 |
|
| 70 |
``` cpp
|
| 71 |
operator "" X(nULL)
|
| 72 |
```
|
| 73 |
|
| 74 |
+
Otherwise, *S* shall contain a raw literal operator or a numeric literal
|
| 75 |
+
operator template [[over.literal]] but not both. If *S* contains a raw
|
| 76 |
+
literal operator, the literal *L* is treated as a call of the form
|
| 77 |
|
| 78 |
``` cpp
|
| 79 |
operator "" X("n{"})
|
| 80 |
```
|
| 81 |
|
| 82 |
+
Otherwise (*S* contains a numeric literal operator template), *L* is
|
| 83 |
+
treated as a call of the form
|
| 84 |
|
| 85 |
``` cpp
|
| 86 |
operator "" X<'c₁', 'c₂', ... 'cₖ'>()
|
| 87 |
```
|
| 88 |
|
| 89 |
where *n* is the source character sequence c₁c₂...cₖ.
|
| 90 |
|
| 91 |
[*Note 1*: The sequence c₁c₂...cₖ can only contain characters from the
|
| 92 |
basic source character set. — *end note*]
|
| 93 |
|
| 94 |
+
If *L* is a *user-defined-floating-point-literal*, let *f* be the
|
| 95 |
+
literal without its *ud-suffix*. If *S* contains a literal operator with
|
| 96 |
parameter type `long double`, the literal *L* is treated as a call of
|
| 97 |
the form
|
| 98 |
|
| 99 |
``` cpp
|
| 100 |
operator "" X(fL)
|
| 101 |
```
|
| 102 |
|
| 103 |
+
Otherwise, *S* shall contain a raw literal operator or a numeric literal
|
| 104 |
+
operator template [[over.literal]] but not both. If *S* contains a raw
|
| 105 |
+
literal operator, the *literal* *L* is treated as a call of the form
|
| 106 |
|
| 107 |
``` cpp
|
| 108 |
operator "" X("f{"})
|
| 109 |
```
|
| 110 |
|
| 111 |
+
Otherwise (*S* contains a numeric literal operator template), *L* is
|
| 112 |
+
treated as a call of the form
|
| 113 |
|
| 114 |
``` cpp
|
| 115 |
operator "" X<'c₁', 'c₂', ... 'cₖ'>()
|
| 116 |
```
|
| 117 |
|
|
|
|
| 120 |
[*Note 2*: The sequence c₁c₂...cₖ can only contain characters from the
|
| 121 |
basic source character set. — *end note*]
|
| 122 |
|
| 123 |
If *L* is a *user-defined-string-literal*, let *str* be the literal
|
| 124 |
without its *ud-suffix* and let *len* be the number of code units in
|
| 125 |
+
*str* (i.e., its length excluding the terminating null character). If
|
| 126 |
+
*S* contains a literal operator template with a non-type template
|
| 127 |
+
parameter for which *str* is a well-formed *template-argument*, the
|
| 128 |
literal *L* is treated as a call of the form
|
| 129 |
|
| 130 |
+
``` cpp
|
| 131 |
+
operator "" X<str>()
|
| 132 |
+
```
|
| 133 |
+
|
| 134 |
+
Otherwise, the literal *L* is treated as a call of the form
|
| 135 |
+
|
| 136 |
``` cpp
|
| 137 |
operator "" X(str, len)
|
| 138 |
```
|
| 139 |
|
| 140 |
If *L* is a *user-defined-character-literal*, let *ch* be the literal
|
| 141 |
+
without its *ud-suffix*. *S* shall contain a literal operator
|
| 142 |
+
[[over.literal]] whose only parameter has the type of *ch* and the
|
| 143 |
literal *L* is treated as a call of the form
|
| 144 |
|
| 145 |
``` cpp
|
| 146 |
operator "" X(ch)
|
| 147 |
```
|
|
|
|
| 160 |
}
|
| 161 |
```
|
| 162 |
|
| 163 |
— *end example*]
|
| 164 |
|
| 165 |
+
In translation phase 6 [[lex.phases]], adjacent *string-literal*s are
|
| 166 |
+
concatenated and *user-defined-string-literal*s are considered
|
| 167 |
+
*string-literal*s for that purpose. During concatenation, *ud-suffix*es
|
| 168 |
+
are removed and ignored and the concatenation process occurs as
|
| 169 |
+
described in [[lex.string]]. At the end of phase 6, if a
|
| 170 |
+
*string-literal* is the result of a concatenation involving at least one
|
| 171 |
*user-defined-string-literal*, all the participating
|
| 172 |
*user-defined-string-literal*s shall have the same *ud-suffix* and that
|
| 173 |
suffix is applied to the result of the concatenation.
|
| 174 |
|
| 175 |
[*Example 3*:
|
|
|
|
| 187 |
[basic.fundamental]: basic.md#basic.fundamental
|
| 188 |
[basic.link]: basic.md#basic.link
|
| 189 |
[basic.lookup.unqual]: basic.md#basic.lookup.unqual
|
| 190 |
[basic.stc]: basic.md#basic.stc
|
| 191 |
[basic.types]: basic.md#basic.types
|
| 192 |
+
[conv.mem]: expr.md#conv.mem
|
| 193 |
+
[conv.ptr]: expr.md#conv.ptr
|
| 194 |
[cpp]: cpp.md#cpp
|
| 195 |
[cpp.concat]: cpp.md#cpp.concat
|
| 196 |
[cpp.cond]: cpp.md#cpp.cond
|
| 197 |
+
[cpp.import]: cpp.md#cpp.import
|
| 198 |
[cpp.include]: cpp.md#cpp.include
|
| 199 |
+
[cpp.module]: cpp.md#cpp.module
|
| 200 |
[cpp.stringize]: cpp.md#cpp.stringize
|
| 201 |
[dcl.attr.grammar]: dcl.md#dcl.attr.grammar
|
| 202 |
[headers]: library.md#headers
|
| 203 |
[lex]: #lex
|
| 204 |
[lex.bool]: #lex.bool
|
| 205 |
[lex.ccon]: #lex.ccon
|
| 206 |
+
[lex.ccon.esc]: #lex.ccon.esc
|
| 207 |
[lex.charset]: #lex.charset
|
| 208 |
[lex.comment]: #lex.comment
|
| 209 |
[lex.digraph]: #lex.digraph
|
| 210 |
[lex.ext]: #lex.ext
|
| 211 |
[lex.fcon]: #lex.fcon
|
| 212 |
+
[lex.fcon.type]: #lex.fcon.type
|
| 213 |
[lex.header]: #lex.header
|
| 214 |
[lex.icon]: #lex.icon
|
| 215 |
+
[lex.icon.base]: #lex.icon.base
|
| 216 |
+
[lex.icon.type]: #lex.icon.type
|
| 217 |
[lex.key]: #lex.key
|
| 218 |
+
[lex.key.digraph]: #lex.key.digraph
|
| 219 |
[lex.literal]: #lex.literal
|
| 220 |
[lex.literal.kinds]: #lex.literal.kinds
|
| 221 |
[lex.name]: #lex.name
|
| 222 |
+
[lex.name.allowed]: #lex.name.allowed
|
| 223 |
+
[lex.name.disallowed]: #lex.name.disallowed
|
| 224 |
+
[lex.name.special]: #lex.name.special
|
| 225 |
[lex.nullptr]: #lex.nullptr
|
| 226 |
[lex.operators]: #lex.operators
|
| 227 |
[lex.phases]: #lex.phases
|
| 228 |
[lex.ppnumber]: #lex.ppnumber
|
| 229 |
[lex.pptoken]: #lex.pptoken
|
| 230 |
[lex.separate]: #lex.separate
|
| 231 |
[lex.string]: #lex.string
|
| 232 |
+
[lex.string.concat]: #lex.string.concat
|
| 233 |
[lex.token]: #lex.token
|
| 234 |
+
[module.import]: module.md#module.import
|
| 235 |
+
[module.unit]: module.md#module.unit
|
| 236 |
[over.literal]: over.md#over.literal
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 237 |
[temp.explicit]: temp.md#temp.explicit
|
| 238 |
[temp.names]: temp.md#temp.names
|
| 239 |
|
| 240 |
[^1]: Implementations must behave as if these separate phases occur,
|
| 241 |
although in practice different phases might be folded together.
|
|
|
|
| 256 |
(described in translation phase 1) is specified as
|
| 257 |
*implementation-defined*, an implementation is required to document
|
| 258 |
how the basic source characters are represented in source files.
|
| 259 |
|
| 260 |
[^5]: A sequence of characters resembling a *universal-character-name*
|
| 261 |
+
in an *r-char-sequence* [[lex.string]] does not form a
|
| 262 |
*universal-character-name*.
|
| 263 |
|
| 264 |
[^6]: These include “digraphs” and additional reserved words. The term
|
| 265 |
“digraph” (token consisting of two characters) is not perfectly
|
| 266 |
+
descriptive, since one of the alternative *preprocessing-token*s is
|
| 267 |
`%:%:` and of course several primary tokens contain two characters.
|
| 268 |
Nonetheless, those alternative tokens that aren’t lexical keywords
|
| 269 |
are colloquially known as “digraphs”.
|
| 270 |
|
| 271 |
+
[^7]: Thus the “stringized” values [[cpp.stringize]] of `[` and `<:`
|
| 272 |
will be different, maintaining the source spelling, but the tokens
|
| 273 |
can otherwise be freely interchanged.
|
| 274 |
|
| 275 |
[^8]: Literals include strings and character and numeric literals.
|
| 276 |
|
|
|
|
| 287 |
long external identifier, but C++ does not place a translation limit
|
| 288 |
on significant characters for external identifiers. In C++, upper-
|
| 289 |
and lower-case letters are considered different for all identifiers,
|
| 290 |
including external identifiers.
|
| 291 |
|
| 292 |
+
[^11]: The term “literal” generally designates, in this document, those
|
| 293 |
+
tokens that are called “constants” in ISO C.
|
| 294 |
|
| 295 |
+
[^12]: They are intended for character sets where a character does not
|
|
|
|
|
|
|
| 296 |
fit into a single byte.
|
| 297 |
|
| 298 |
+
[^13]: Using an escape sequence for a question mark is supported for
|
| 299 |
compatibility with ISO C++14 and ISO C.
|