Mit C++ 0x, wie erfasse ich eine Variable, wenn ich ein Lambda innerhalb eines Lambda habe? Zum Beispiel:Closure und verschachtelte Lambdas in C++ 0x
std::vector<int> c1;
int v = 10; <--- I want to capture this variable
std::for_each(
c1.begin(),
c1.end(),
[v](int num) <--- This is fine...
{
std::vector<int> c2;
std::for_each(
c2.begin(),
c2.end(),
[v](int num) <--- error on this line, how do I recapture v?
{
// Do something
});
});
Ich würde vermuten, die Variable in dem ersten Verschluss zuweisen könnte helfen. –
Das obige ist gut auf gcc4.5 - verwenden Sie VC10? –
Ja, VC10. Ich werde es Microsoft melden. – DanDan