tmp/tmp5_0wbnpd/{from.md → to.md}
RENAMED
|
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
### Expression splicing <a id="expr.prim.splice">[[expr.prim.splice]]</a>
|
| 2 |
+
|
| 3 |
+
``` bnf
|
| 4 |
+
splice-expression:
|
| 5 |
+
splice-specifier
|
| 6 |
+
template splice-specifier
|
| 7 |
+
template splice-specialization-specifier
|
| 8 |
+
```
|
| 9 |
+
|
| 10 |
+
A *splice-specifier* or *splice-specialization-specifier* immediately
|
| 11 |
+
followed by `::` or preceded by `typename` is never interpreted as part
|
| 12 |
+
of a *splice-expression*.
|
| 13 |
+
|
| 14 |
+
[*Example 1*:
|
| 15 |
+
|
| 16 |
+
``` cpp
|
| 17 |
+
struct S { static constexpr int a = 1; };
|
| 18 |
+
template<typename> struct TCls { static constexpr int b = 2; };
|
| 19 |
+
|
| 20 |
+
constexpr int c = [:^^S:]::a; // OK, [:^^ S:] is not an expression
|
| 21 |
+
constexpr int d = template [:^^TCls:]<int>::b; // OK, template [:^^ TCls:]<int> is not an expression
|
| 22 |
+
template<auto V> constexpr int e = [:V:]; // OK
|
| 23 |
+
constexpr int f = template [:^^e:]<^^S::a>; // OK
|
| 24 |
+
|
| 25 |
+
constexpr auto g = typename [:^^int:](42); // OK, typename [:^^ int:] is a splice-type-specifier
|
| 26 |
+
|
| 27 |
+
constexpr auto h = ^^g;
|
| 28 |
+
constexpr auto i = e<[:^^h:]>; // error: unparenthesized splice-expression used as template argument
|
| 29 |
+
constexpr auto j = e<([:^^h:])>; // OK
|
| 30 |
+
```
|
| 31 |
+
|
| 32 |
+
— *end example*]
|
| 33 |
+
|
| 34 |
+
For a *splice-expression* of the form *splice-specifier*, let S be the
|
| 35 |
+
construct designated by *splice-specifier*.
|
| 36 |
+
|
| 37 |
+
- The expression is ill-formed if S is
|
| 38 |
+
- a constructor,
|
| 39 |
+
- a destructor,
|
| 40 |
+
- an unnamed bit-field, or
|
| 41 |
+
- a local entity [[basic.pre]] such that
|
| 42 |
+
- there is a lambda scope that intervenes between the expression and
|
| 43 |
+
the point at which S was introduced and
|
| 44 |
+
- the expression would be potentially evaluated if the effect of any
|
| 45 |
+
enclosing `typeid` expressions [[expr.typeid]] were ignored.
|
| 46 |
+
- Otherwise, if S is a function F, the expression denotes an overload
|
| 47 |
+
set containing all declarations of F that precede either the
|
| 48 |
+
expression or the point immediately following the *class-specifier* of
|
| 49 |
+
the outermost class for which the expression is in a complete-class
|
| 50 |
+
context; overload resolution is performed
|
| 51 |
+
[[over.match]], [[over.over]].
|
| 52 |
+
- Otherwise, if S is an object or a non-static data member, the
|
| 53 |
+
expression is an lvalue designating S. The expression has the same
|
| 54 |
+
type as that of S, and is a bit-field if and only if S is a bit-field.
|
| 55 |
+
\[*Note 1*: The implicit transformation whereby an *id-expression*
|
| 56 |
+
denoting a non-static member becomes a class member access
|
| 57 |
+
[[expr.prim.id]] does not apply to a
|
| 58 |
+
*splice-expression*. — *end note*]
|
| 59 |
+
- Otherwise, if S is a variable or a structured binding, S shall either
|
| 60 |
+
have static or thread storage duration or shall inhabit a scope
|
| 61 |
+
enclosing the expression. The expression is an lvalue referring to the
|
| 62 |
+
object or function X associated with or referenced by S, has the same
|
| 63 |
+
type as that of S, and is a bit-field if and only if X is a bit-field.
|
| 64 |
+
\[*Note 2*: The type of a *splice-expression* designating a variable
|
| 65 |
+
or structured binding of reference type will be adjusted to a
|
| 66 |
+
non-reference type [[expr.type]]. — *end note*]
|
| 67 |
+
- Otherwise, if S is a value or an enumerator, the expression is a
|
| 68 |
+
prvalue that computes S and whose type is the same as that of S.
|
| 69 |
+
- Otherwise, the expression is ill-formed.
|
| 70 |
+
|
| 71 |
+
For a *splice-expression* of the form `template splice-specifier`, the
|
| 72 |
+
*splice-specifier* shall designate a function template T that is not a
|
| 73 |
+
constructor template. The expression denotes an overload set containing
|
| 74 |
+
all declarations of T that precede either the expression or the point
|
| 75 |
+
immediately following the *class-specifier* of the outermost class for
|
| 76 |
+
which the expression is in a complete-class context; overload resolution
|
| 77 |
+
is performed.
|
| 78 |
+
|
| 79 |
+
[*Note 3*: During overload resolution, candidate function templates
|
| 80 |
+
undergo template argument deduction and the resulting specializations
|
| 81 |
+
are considered as candidate functions. — *end note*]
|
| 82 |
+
|
| 83 |
+
For a *splice-expression* of the form
|
| 84 |
+
`template splice-specialization-specifier`, the *splice-specifier* of
|
| 85 |
+
the *splice-specialization-specifier* shall designate a template T.
|
| 86 |
+
|
| 87 |
+
- If T is a function template, the expression denotes an overload set
|
| 88 |
+
containing all declarations of T that precede either the expression or
|
| 89 |
+
the point immediately following the *class-specifier* of the outermost
|
| 90 |
+
class for which the expression is in a complete-class context;
|
| 91 |
+
overload resolution is performed [[over.match]], [[over.over]].
|
| 92 |
+
- Otherwise, if T is a variable template, let S be the specialization of
|
| 93 |
+
T corresponding to the template argument list of the
|
| 94 |
+
*splice-specialization-specifier*. The expression is an lvalue
|
| 95 |
+
referring to the object associated with S and has the same type as
|
| 96 |
+
that of S.
|
| 97 |
+
- Otherwise, the expression is ill-formed.
|
| 98 |
+
|
| 99 |
+
[*Note 4*: Class members are accessible from any point when designated
|
| 100 |
+
by *splice-expression*s [[class.access.base]]. A class member access
|
| 101 |
+
expression [[expr.ref]] whose right operand is a *splice-expression* is
|
| 102 |
+
ill-formed if the left operand (considered as a pointer) cannot be
|
| 103 |
+
implicitly converted to a pointer to the designating class of the right
|
| 104 |
+
operand. — *end note*]
|
| 105 |
+
|