From Jason Turner

[dcl.type.decltype]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpu5xpmxs8/{from.md → to.md} +14 -2
tmp/tmpu5xpmxs8/{from.md → to.md} RENAMED
@@ -10,17 +10,20 @@ follows:
10
 
11
  - if E is an unparenthesized *id-expression* naming a structured binding
12
  [[dcl.struct.bind]], `decltype(E)` is the referenced type as given in
13
  the specification of the structured binding declaration;
14
  - otherwise, if E is an unparenthesized *id-expression* naming a
15
- non-type *template-parameter* [[temp.param]], `decltype(E)` is the
16
- type of the *template-parameter* after performing any necessary type
17
  deduction [[dcl.spec.auto]], [[dcl.type.class.deduct]];
18
  - otherwise, if E is an unparenthesized *id-expression* or an
19
  unparenthesized class member access [[expr.ref]], `decltype(E)` is the
20
  type of the entity named by E. If there is no such entity, the program
21
  is ill-formed;
 
 
 
22
  - otherwise, if E is an xvalue, `decltype(E)` is `T&&`, where `T` is the
23
  type of E;
24
  - otherwise, if E is an lvalue, `decltype(E)` is `T&`, where `T` is the
25
  type of E;
26
  - otherwise, `decltype(E)` is the type of E.
@@ -37,10 +40,19 @@ struct A { double x; };
37
  const A* a = new A();
38
  decltype(foo()) x1 = 17; // type is const int&&
39
  decltype(i) x2; // type is int
40
  decltype(a->x) x3; // type is double
41
  decltype((a->x)) x4 = x3; // type is const double&
 
 
 
 
 
 
 
 
 
42
  ```
43
 
44
  — *end example*]
45
 
46
  [*Note 1*: The rules for determining types involving `decltype(auto)`
 
10
 
11
  - if E is an unparenthesized *id-expression* naming a structured binding
12
  [[dcl.struct.bind]], `decltype(E)` is the referenced type as given in
13
  the specification of the structured binding declaration;
14
  - otherwise, if E is an unparenthesized *id-expression* naming a
15
+ constant template parameter [[temp.param]], `decltype(E)` is the type
16
+ of the template parameter after performing any necessary type
17
  deduction [[dcl.spec.auto]], [[dcl.type.class.deduct]];
18
  - otherwise, if E is an unparenthesized *id-expression* or an
19
  unparenthesized class member access [[expr.ref]], `decltype(E)` is the
20
  type of the entity named by E. If there is no such entity, the program
21
  is ill-formed;
22
+ - otherwise, if E is an unparenthesized *splice-expression*,
23
+ `decltype(E)` is the type of the entity, object, or value designated
24
+ by the *splice-specifier* of E;
25
  - otherwise, if E is an xvalue, `decltype(E)` is `T&&`, where `T` is the
26
  type of E;
27
  - otherwise, if E is an lvalue, `decltype(E)` is `T&`, where `T` is the
28
  type of E;
29
  - otherwise, `decltype(E)` is the type of E.
 
40
  const A* a = new A();
41
  decltype(foo()) x1 = 17; // type is const int&&
42
  decltype(i) x2; // type is int
43
  decltype(a->x) x3; // type is double
44
  decltype((a->x)) x4 = x3; // type is const double&
45
+ decltype([:^^x1:]) x5 = 18; // type is const int&&
46
+ decltype(([:^^x1:])) x6 = 19; // type is const int&
47
+
48
+ void f() {
49
+ [](auto ...pack) {
50
+ decltype(pack...[0]) x7; // type is int
51
+ decltype((pack...[0])) x8; // type is int&
52
+ }(0);
53
+ }
54
  ```
55
 
56
  — *end example*]
57
 
58
  [*Note 1*: The rules for determining types involving `decltype(auto)`