// 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-do compile { target c++11 } } template struct same_type; template struct same_type { }; int main() { int i; [=] { same_type(); same_type(); i+1; same_type(); same_type(); }; [=] { same_type(); same_type(); same_type(); }; [=] () mutable { same_type(); same_type(); same_type(); }; [&] { same_type(); same_type(); same_type(); }; [i] { same_type(); same_type(); }; [&,i] { same_type(); same_type(); }; [i] () mutable { same_type(); same_type(); }; [&,i] () mutable { same_type(); same_type(); }; [&i] { same_type(); same_type(); }; [=,&i] { same_type(); same_type(); }; [] { same_type(); same_type(); // { dg-error "" "not captured" } }; }