lambdas are syntax sugar for anonymous structs with an operator().
Your lambda written above desugars into:
struct _AnonymousLambda {
int operator()() {
return 10;
}
};
Thus, doSome is equivalent to:
function<int()> doSome() {
return _AnonymousLambda();
}
No JavaScript closures in sight. :)
On Tue, Aug 26, 2014 at 12:20 AM, Jack <[email protected]> wrote:
> Hi
>
> If I write a c++ lambda function like:
>
> function<int()> doSome()
> {
> auto f = []() {
> return 10;
> };
> return f;
> }
>
> function<int()> func = doSome();
>
> I wonder what's the rule when emscripten encounters a lambda function.
> Will it compile to like a closure function or what ?
>
> Thank you :)
>
> --
> You received this message because you are subscribed to the Google Groups
> "emscripten-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
Chad Austin
Technical Director, IMVU
http://engineering.imvu.com <http://www.imvu.com/members/Chad/>
http://chadaustin.me
--
You received this message because you are subscribed to the Google Groups
"emscripten-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.