Quote:
Originally Posted by chants
3) as far as I know its the captures that are on the temporary object, and the actual function arguments are passed per __thiscall logic.
|
Oops, you're right. I knew that but mixed up the terminology (captures vs arguments), heh.
Here's an example of how MSVC seems to implement lambdas:
Code:
bool normal_function()
{
int a, b, c;
int d = 0;
int e = 0;
int f = 0;
return [a, b, c](int, int, int) -> bool {
return true;
}(d, e, f);
}
Which is compiled into something resembling this:
Code:
bool normal_function()
{
class lambda_class
{
int *a_;
int *b_;
int *c_;
public:
lambda_class(int *a, int *b, int *c)
: a_(a), b_(c), c_(c)
{
}
bool operator()(int d, int e, int f)
{
return true;
}
};
int a, b, c;
int d = 0;
int e = 0;
int f = 0;
return lambda_class(&a, &b, &c)(d, e, f);
}