URL
https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk
Subversion Repositories openrisc_me
[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [g++.dg/] [cpp0x/] [lambda/] [lambda-type.C] - Rev 307
Go to most recent revision | Compare with Previous | Blame | View Log
// 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" }
};
}
Go to most recent revision | Compare with Previous | Blame | View Log