On 9/13/16 4:11 PM, Yuxuan Shui wrote:
On Tuesday, 13 September 2016 at 20:00:40 UTC, Steven Schveighoffer wrote:
Not familiar with C++ lambda. You can always "specify" how to capture
the data by directly declaring it:
auto foo()
{
int x;
static struct S
{
int x;
}
return S(x);
}
It just feels a bit tedious to do something manually while the compiler
have enough information to do it for me.
Do what for you? How does it know that you don't want to use a closure
and a reference to that instead?
Note that all the internals for this are implementation defined. Given
sufficient conditions, the compiler could "cheat" and allocate the data
inside the struct itself instead. For example, if all referenced data
was immutable.
-Steve