From Jason Turner

[basic.splice]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpg3tdxomt/{from.md → to.md} +59 -0
tmp/tmpg3tdxomt/{from.md → to.md} RENAMED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ## Splice specifiers <a id="basic.splice">[[basic.splice]]</a>
2
+
3
+ ``` bnf
4
+ splice-specifier:
5
+ '[:' constant-expression ':]'
6
+ ```
7
+
8
+ ``` bnf
9
+ splice-specialization-specifier:
10
+ splice-specifier '<' template-argument-listₒₚₜ '>'
11
+ ```
12
+
13
+ The *constant-expression* of a *splice-specifier* shall be a converted
14
+ constant expression of type `std::meta::info` [[expr.const]]. A
15
+ *splice-specifier* whose converted *constant-expression* represents a
16
+ construct X is said to *designate* either
17
+
18
+ - the underlying entity of X if X is an entity [[basic.pre]], or
19
+ - X otherwise.
20
+
21
+ [*Note 1*: A *splice-specifier* is dependent if the converted
22
+ *constant-expression* is value-dependent
23
+ [[temp.dep.splice]]. — *end note*]
24
+
25
+ A non-dependent *splice-specifier* of a
26
+ *splice-specialization-specifier* shall designate a template.
27
+
28
+ [*Note 2*:
29
+
30
+ A `<` following a *splice-specifier* is interpreted as the delimiter of
31
+ a *template-argument-list* when the *splice-specifier* is preceded by
32
+ the keyword `template` or the keyword `typename`, or when it appears in
33
+ a type-only context [[temp.names]].
34
+
35
+ [*Example 1*:
36
+
37
+ ``` cpp
38
+ constexpr int v = 1;
39
+ template<int V> struct TCls {
40
+ static constexpr int s = V + 1;
41
+ };
42
+
43
+ using alias = [:^^TCls:]<([:^^v:])>;
44
+ // OK, a splice-specialization-specifier with a parenthesized splice-expression as a template argument
45
+
46
+ static_assert(alias::s == 2);
47
+
48
+ auto o1 = [:^^TCls:]<([:^^v:])>(); // error: < means less than
49
+ auto o2 = typename [:^^TCls:]<([:^^v:])>(); // OK, o2 is an object of type TCls<1>
50
+
51
+ consteval int bad_splice(std::meta::info v) {
52
+ return [:v:]; // error: v is not constant
53
+ }
54
+ ```
55
+
56
+ — *end example*]
57
+
58
+ — *end note*]
59
+