- tmp/tmpsvdqu73k/{from.md → to.md} +206 -20
tmp/tmpsvdqu73k/{from.md → to.md}
RENAMED
|
@@ -1,11 +1,11 @@
|
|
| 1 |
-
##
|
| 2 |
|
| 3 |
``` bnf
|
| 4 |
literal-operator-id:
|
| 5 |
-
|
| 6 |
-
|
| 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
|
|
@@ -15,71 +15,257 @@ 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
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
|
| 26 |
The declaration of a literal operator shall have a
|
| 27 |
*parameter-declaration-clause* equivalent to one of the following:
|
| 28 |
|
| 29 |
``` cpp
|
| 30 |
const char*
|
| 31 |
unsigned long long int
|
| 32 |
long double
|
| 33 |
char
|
| 34 |
wchar_t
|
|
|
|
| 35 |
char16_t
|
| 36 |
char32_t
|
| 37 |
const char*, std::size_t
|
| 38 |
const wchar_t*, std::size_t
|
|
|
|
| 39 |
const char16_t*, std::size_t
|
| 40 |
const char32_t*, std::size_t
|
| 41 |
```
|
| 42 |
|
| 43 |
-
If a parameter has a default argument
|
| 44 |
-
|
| 45 |
|
| 46 |
A *raw literal operator* is a literal operator with a single parameter
|
| 47 |
whose type is `const char*`.
|
| 48 |
|
| 49 |
-
|
| 50 |
-
*parameter-
|
| 51 |
-
|
| 52 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
| 59 |
-
|
| 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
|
| 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
|
| 76 |
-
double operator"" _Bq(long double); // uses the reserved identifier _Bq
|
| 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 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|
|
|
|
| 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 instantiation
|
| 21 |
+
or specialization of a function template, or a *using-declaration*
|
| 22 |
+
[[namespace.udecl]]. A function declared with a *literal-operator-id* is
|
| 23 |
+
a *literal operator*. A function template declared with a
|
| 24 |
+
*literal-operator-id* is a *literal operator template*.
|
| 25 |
|
| 26 |
The declaration of a literal operator shall have a
|
| 27 |
*parameter-declaration-clause* equivalent to one of the following:
|
| 28 |
|
| 29 |
``` cpp
|
| 30 |
const char*
|
| 31 |
unsigned long long int
|
| 32 |
long double
|
| 33 |
char
|
| 34 |
wchar_t
|
| 35 |
+
char8_t
|
| 36 |
char16_t
|
| 37 |
char32_t
|
| 38 |
const char*, std::size_t
|
| 39 |
const wchar_t*, std::size_t
|
| 40 |
+
const char8_t*, std::size_t
|
| 41 |
const char16_t*, std::size_t
|
| 42 |
const char32_t*, std::size_t
|
| 43 |
```
|
| 44 |
|
| 45 |
+
If a parameter has a default argument [[dcl.fct.default]], the program
|
| 46 |
+
is ill-formed.
|
| 47 |
|
| 48 |
A *raw literal operator* is a literal operator with a single parameter
|
| 49 |
whose type is `const char*`.
|
| 50 |
|
| 51 |
+
A *numeric literal operator template* is a literal operator template
|
| 52 |
+
whose *template-parameter-list* has a single *template-parameter* that
|
| 53 |
+
is a non-type template parameter pack [[temp.variadic]] with element
|
| 54 |
+
type `char`. A *string literal operator template* is a literal operator
|
| 55 |
+
template whose *template-parameter-list* comprises a single non-type
|
| 56 |
+
*template-parameter* of class type. The declaration of a literal
|
| 57 |
+
operator template shall have an empty *parameter-declaration-clause* and
|
| 58 |
+
shall declare either a numeric literal operator template or a string
|
| 59 |
+
literal operator template.
|
| 60 |
|
| 61 |
Literal operators and literal operator templates shall not have C
|
| 62 |
language linkage.
|
| 63 |
|
| 64 |
[*Note 1*: Literal operators and literal operator templates are usually
|
| 65 |
+
invoked implicitly through user-defined literals [[lex.ext]]. However,
|
| 66 |
+
except for the constraints described above, they are ordinary
|
| 67 |
namespace-scope functions and function templates. In particular, they
|
| 68 |
are looked up like ordinary functions and function templates and they
|
| 69 |
follow the same overload resolution rules. Also, they can be declared
|
| 70 |
+
`inline` or `constexpr`, they may have internal, module, or external
|
| 71 |
+
linkage, they can be called explicitly, their addresses can be taken,
|
| 72 |
etc. — *end note*]
|
| 73 |
|
| 74 |
[*Example 1*:
|
| 75 |
|
| 76 |
``` cpp
|
| 77 |
void operator "" _km(long double); // OK
|
| 78 |
string operator "" _i18n(const char*, std::size_t); // OK
|
| 79 |
template <char...> double operator "" _\u03C0(); // OK: UCN for lowercase pi
|
| 80 |
float operator ""_e(const char*); // OK
|
| 81 |
float operator ""E(const char*); // error: reserved literal suffix~([usrlit.suffix], [lex.ext])
|
| 82 |
+
double operator""_Bq(long double); // OK: does not use the reserved identifier _Bq[lex.name]
|
| 83 |
+
double operator"" _Bq(long double); // uses the reserved identifier _Bq[lex.name]
|
| 84 |
float operator " " B(const char*); // error: non-empty string-literal
|
| 85 |
string operator "" 5X(const char*, std::size_t); // error: invalid literal suffix identifier
|
| 86 |
double operator "" _miles(double); // error: invalid parameter-declaration-clause
|
| 87 |
template <char...> int operator "" _j(const char*); // error: invalid parameter-declaration-clause
|
| 88 |
extern "C" void operator "" _m(long double); // error: C language linkage
|
| 89 |
```
|
| 90 |
|
| 91 |
— *end example*]
|
| 92 |
|
| 93 |
+
<!-- Link reference definitions -->
|
| 94 |
+
[basic.lookup]: basic.md#basic.lookup
|
| 95 |
+
[basic.lookup.argdep]: basic.md#basic.lookup.argdep
|
| 96 |
+
[basic.stc.dynamic]: basic.md#basic.stc.dynamic
|
| 97 |
+
[class.access]: class.md#class.access
|
| 98 |
+
[class.conv]: class.md#class.conv
|
| 99 |
+
[class.conv.ctor]: class.md#class.conv.ctor
|
| 100 |
+
[class.conv.fct]: class.md#class.conv.fct
|
| 101 |
+
[class.copy.assign]: class.md#class.copy.assign
|
| 102 |
+
[class.copy.ctor]: class.md#class.copy.ctor
|
| 103 |
+
[class.friend]: class.md#class.friend
|
| 104 |
+
[class.inhctor.init]: class.md#class.inhctor.init
|
| 105 |
+
[class.mem]: class.md#class.mem
|
| 106 |
+
[class.member.lookup]: class.md#class.member.lookup
|
| 107 |
+
[class.mfct]: class.md#class.mfct
|
| 108 |
+
[class.static]: class.md#class.static
|
| 109 |
+
[class.this]: class.md#class.this
|
| 110 |
+
[conv]: expr.md#conv
|
| 111 |
+
[conv.array]: expr.md#conv.array
|
| 112 |
+
[conv.bool]: expr.md#conv.bool
|
| 113 |
+
[conv.double]: expr.md#conv.double
|
| 114 |
+
[conv.fctptr]: expr.md#conv.fctptr
|
| 115 |
+
[conv.fpint]: expr.md#conv.fpint
|
| 116 |
+
[conv.fpprom]: expr.md#conv.fpprom
|
| 117 |
+
[conv.func]: expr.md#conv.func
|
| 118 |
+
[conv.integral]: expr.md#conv.integral
|
| 119 |
+
[conv.lval]: expr.md#conv.lval
|
| 120 |
+
[conv.mem]: expr.md#conv.mem
|
| 121 |
+
[conv.prom]: expr.md#conv.prom
|
| 122 |
+
[conv.ptr]: expr.md#conv.ptr
|
| 123 |
+
[conv.qual]: expr.md#conv.qual
|
| 124 |
+
[cpp.concat]: cpp.md#cpp.concat
|
| 125 |
+
[cpp.stringize]: cpp.md#cpp.stringize
|
| 126 |
+
[dcl.array]: dcl.md#dcl.array
|
| 127 |
+
[dcl.decl]: dcl.md#dcl.decl
|
| 128 |
+
[dcl.fct]: dcl.md#dcl.fct
|
| 129 |
+
[dcl.fct.def.delete]: dcl.md#dcl.fct.def.delete
|
| 130 |
+
[dcl.fct.default]: dcl.md#dcl.fct.default
|
| 131 |
+
[dcl.fct.spec]: dcl.md#dcl.fct.spec
|
| 132 |
+
[dcl.init]: dcl.md#dcl.init
|
| 133 |
+
[dcl.init.aggr]: dcl.md#dcl.init.aggr
|
| 134 |
+
[dcl.init.list]: dcl.md#dcl.init.list
|
| 135 |
+
[dcl.init.ref]: dcl.md#dcl.init.ref
|
| 136 |
+
[dcl.init.string]: dcl.md#dcl.init.string
|
| 137 |
+
[dcl.type.class.deduct]: dcl.md#dcl.type.class.deduct
|
| 138 |
+
[dcl.type.simple]: dcl.md#dcl.type.simple
|
| 139 |
+
[dcl.typedef]: dcl.md#dcl.typedef
|
| 140 |
+
[except.spec]: except.md#except.spec
|
| 141 |
+
[expr.arith.conv]: expr.md#expr.arith.conv
|
| 142 |
+
[expr.ass]: expr.md#expr.ass
|
| 143 |
+
[expr.await]: expr.md#expr.await
|
| 144 |
+
[expr.call]: expr.md#expr.call
|
| 145 |
+
[expr.cast]: expr.md#expr.cast
|
| 146 |
+
[expr.compound]: expr.md#expr.compound
|
| 147 |
+
[expr.cond]: expr.md#expr.cond
|
| 148 |
+
[expr.eq]: expr.md#expr.eq
|
| 149 |
+
[expr.mptr.oper]: expr.md#expr.mptr.oper
|
| 150 |
+
[expr.pre.incr]: expr.md#expr.pre.incr
|
| 151 |
+
[expr.prim.paren]: expr.md#expr.prim.paren
|
| 152 |
+
[expr.rel]: expr.md#expr.rel
|
| 153 |
+
[expr.spaceship]: expr.md#expr.spaceship
|
| 154 |
+
[expr.static.cast]: expr.md#expr.static.cast
|
| 155 |
+
[expr.sub]: expr.md#expr.sub
|
| 156 |
+
[expr.type.conv]: expr.md#expr.type.conv
|
| 157 |
+
[expr.unary.op]: expr.md#expr.unary.op
|
| 158 |
+
[lex.ext]: lex.md#lex.ext
|
| 159 |
+
[namespace.udecl]: dcl.md#namespace.udecl
|
| 160 |
+
[over]: #over
|
| 161 |
+
[over.ass]: #over.ass
|
| 162 |
+
[over.best.ics]: #over.best.ics
|
| 163 |
+
[over.binary]: #over.binary
|
| 164 |
+
[over.built]: #over.built
|
| 165 |
+
[over.call]: #over.call
|
| 166 |
+
[over.call.func]: #over.call.func
|
| 167 |
+
[over.call.object]: #over.call.object
|
| 168 |
+
[over.dcl]: #over.dcl
|
| 169 |
+
[over.ics.ellipsis]: #over.ics.ellipsis
|
| 170 |
+
[over.ics.list]: #over.ics.list
|
| 171 |
+
[over.ics.rank]: #over.ics.rank
|
| 172 |
+
[over.ics.ref]: #over.ics.ref
|
| 173 |
+
[over.ics.scs]: #over.ics.scs
|
| 174 |
+
[over.ics.user]: #over.ics.user
|
| 175 |
+
[over.inc]: #over.inc
|
| 176 |
+
[over.literal]: #over.literal
|
| 177 |
+
[over.load]: #over.load
|
| 178 |
+
[over.match]: #over.match
|
| 179 |
+
[over.match.best]: #over.match.best
|
| 180 |
+
[over.match.call]: #over.match.call
|
| 181 |
+
[over.match.class.deduct]: #over.match.class.deduct
|
| 182 |
+
[over.match.conv]: #over.match.conv
|
| 183 |
+
[over.match.copy]: #over.match.copy
|
| 184 |
+
[over.match.ctor]: #over.match.ctor
|
| 185 |
+
[over.match.funcs]: #over.match.funcs
|
| 186 |
+
[over.match.list]: #over.match.list
|
| 187 |
+
[over.match.oper]: #over.match.oper
|
| 188 |
+
[over.match.ref]: #over.match.ref
|
| 189 |
+
[over.match.viable]: #over.match.viable
|
| 190 |
+
[over.oper]: #over.oper
|
| 191 |
+
[over.over]: #over.over
|
| 192 |
+
[over.pre]: #over.pre
|
| 193 |
+
[over.ref]: #over.ref
|
| 194 |
+
[over.sub]: #over.sub
|
| 195 |
+
[over.unary]: #over.unary
|
| 196 |
+
[stmt.return]: stmt.md#stmt.return
|
| 197 |
+
[temp.arg.explicit]: temp.md#temp.arg.explicit
|
| 198 |
+
[temp.arg.nontype]: temp.md#temp.arg.nontype
|
| 199 |
+
[temp.constr.constr]: temp.md#temp.constr.constr
|
| 200 |
+
[temp.constr.decl]: temp.md#temp.constr.decl
|
| 201 |
+
[temp.constr.order]: temp.md#temp.constr.order
|
| 202 |
+
[temp.deduct]: temp.md#temp.deduct
|
| 203 |
+
[temp.deduct.funcaddr]: temp.md#temp.deduct.funcaddr
|
| 204 |
+
[temp.deduct.type]: temp.md#temp.deduct.type
|
| 205 |
+
[temp.dep]: temp.md#temp.dep
|
| 206 |
+
[temp.dep.type]: temp.md#temp.dep.type
|
| 207 |
+
[temp.func.order]: temp.md#temp.func.order
|
| 208 |
+
[temp.over]: temp.md#temp.over
|
| 209 |
+
[temp.over.link]: temp.md#temp.over.link
|
| 210 |
+
[temp.variadic]: temp.md#temp.variadic
|
| 211 |
+
[usrlit.suffix]: library.md#usrlit.suffix
|
| 212 |
+
|
| 213 |
+
[^1]: When a parameter type includes a function type, such as in the
|
| 214 |
+
case of a parameter type that is a pointer to function, the `const`
|
| 215 |
+
and `volatile` type-specifiers at the outermost level of the
|
| 216 |
+
parameter type specifications for the inner function type are also
|
| 217 |
+
ignored.
|
| 218 |
+
|
| 219 |
+
[^2]: The process of argument deduction fully determines the parameter
|
| 220 |
+
types of the function template specializations, i.e., the parameters
|
| 221 |
+
of function template specializations contain no template parameter
|
| 222 |
+
types. Therefore, except where specified otherwise, function
|
| 223 |
+
template specializations and non-template functions [[dcl.fct]] are
|
| 224 |
+
treated equivalently for the remainder of overload resolution.
|
| 225 |
+
|
| 226 |
+
[^3]: Note that cv-qualifiers on the type of objects are significant in
|
| 227 |
+
overload resolution for both glvalue and class prvalue objects.
|
| 228 |
+
|
| 229 |
+
[^4]: An implied object argument must be contrived to correspond to the
|
| 230 |
+
implicit object parameter attributed to member functions during
|
| 231 |
+
overload resolution. It is not used in the call to the selected
|
| 232 |
+
function. Since the member functions all have the same implicit
|
| 233 |
+
object parameter, the contrived object will not be the cause to
|
| 234 |
+
select or reject a function.
|
| 235 |
+
|
| 236 |
+
[^5]: Note that this construction can yield candidate call functions
|
| 237 |
+
that cannot be differentiated one from the other by overload
|
| 238 |
+
resolution because they have identical declarations or differ only
|
| 239 |
+
in their return type. The call will be ambiguous if overload
|
| 240 |
+
resolution cannot select a match to the call that is uniquely better
|
| 241 |
+
than such undifferentiable functions.
|
| 242 |
+
|
| 243 |
+
[^6]: If the set of candidate functions is empty, overload resolution is
|
| 244 |
+
unsuccessful.
|
| 245 |
+
|
| 246 |
+
[^7]: If the value returned by the `operator->` function has class type,
|
| 247 |
+
this may result in selecting and calling another `operator->`
|
| 248 |
+
function. The process repeats until an `operator->` function returns
|
| 249 |
+
a value of non-class type.
|
| 250 |
+
|
| 251 |
+
[^8]: If a function is a static member function, this definition means
|
| 252 |
+
that the first argument, the implied object argument, has no effect
|
| 253 |
+
in the determination of whether the function is better or worse than
|
| 254 |
+
any other function.
|
| 255 |
+
|
| 256 |
+
[^9]: The algorithm for selecting the best viable function is linear in
|
| 257 |
+
the number of viable functions. Run a simple tournament to find a
|
| 258 |
+
function `W` that is not worse than any opponent it faced. Although
|
| 259 |
+
another function `F` that `W` did not face might be at least as good
|
| 260 |
+
as `W`, `F` cannot be the best function because at some point in the
|
| 261 |
+
tournament `F` encountered another function `G` such that `F` was
|
| 262 |
+
not better than `G`. Hence, either `W` is the best function or there
|
| 263 |
+
is no best function. So, make a second pass over the viable
|
| 264 |
+
functions to verify that `W` is better than all other functions.
|
| 265 |
+
|
| 266 |
+
[^10]: Since there are no parameters of array type, this will only occur
|
| 267 |
+
as the referenced type of a reference parameter.
|
| 268 |
+
|
| 269 |
+
[^11]: Calling `operator++` explicitly, as in expressions like
|
| 270 |
+
`a.operator++(2)`, has no special properties: The argument to
|
| 271 |
+
`operator++` is `2`.
|