1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
// Every id-expression that is a use (_basic.def.odr_ 3.2) of an entity
// captured by copy is transformed into an access to the corresponding
// unnamed data member of the closure type.
//...
// Every occurrence of decltype((x)) where x is a possibly parenthesized
// id-expression that names an entity of automatic storage duration is
// treated as if x were transformed into an access to a corresponding data
// member of the closure type that would have been declared if x were a use
// of the denoted entity.
// So, other appearances of 'x' within decltype do not refer to the closure
// member, because they are not "use"s in the sense of 3.2.
// { dg-options -std=c++0x }
template<class T, class U>
struct same_type;
template <class T>
struct same_type<T,T> { };
int main()
{
int i;
[=] {
same_type<decltype(i),int>();
same_type<decltype((i)),int const&>();
i+1;
same_type<decltype((i)),int const&>();
same_type<decltype(i),int>();
};
[=] {
same_type<decltype(i),int>();
same_type<decltype((i)),int const&>();
same_type<decltype(i),int>();
};
[=] () mutable {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
same_type<decltype(i),int>();
};
[&] {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
same_type<decltype(i),int>();
};
[i] {
same_type<decltype(i),int>();
same_type<decltype((i)),int const&>();
};
[&,i] {
same_type<decltype(i),int>();
same_type<decltype((i)),int const&>();
};
[i] () mutable {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
};
[&,i] () mutable {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
};
[&i] {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
};
[=,&i] {
same_type<decltype(i),int>();
same_type<decltype((i)),int &>();
};
[] {
same_type<decltype(i),int>();
same_type<decltype((i)),int const&>(); // { dg-error "" "not captured" }
};
}
|