Probably ;-)

What I mean is, calling the lambda by patching executable code can be replaced by

1. serializing/deserializing the lambda object

2. potentially creating a bind to call the lambda

 

So the idea should not focus on calling lambdas specifically, but on serializing/deserializing C++ objects or generically calling member functions instead. There is nothing special about lambda functions in that regard as far as I can see.

 

For both of those there exists a lot of approaches (which can be further improved perhaps) and the use cases are much wider.


 

-----Ursprüngliche Nachricht-----
Von: Giuseppe D‘Angelo via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Fr 14.04.2023 17:50
Betreff: Re: [std-proposals] Function Pointer from Lambda with Captures
Anlage: untitled
An: std-proposals@lists.isocpp.org;
CC: Giuseppe D‘Angelo <giuseppe.dangelo@kdab.com>;
Hi,

Il 14/04/23 17:28, Sebastian Wittmeier via Std-Proposals ha scritto:
> Wouldn't it be nice, if C++ lambdas were of class type, storing the
> captures in its member variables, and calling the lambda would call its
> () operator?
>
> Something like
>
> |int x = 4; ||struct { int& b; void operator()(int a) { return a + b + 1; } } lambda1
> = { x }; x = 15; std::cout << lambda1(2) << std::endl; // prints out 18 |


Was there a <satire> tag missing? Because that's precisely what a lambda
is, an instance of a closure type.

https://eel.is/c++draft/expr.prim.lambda.closure

My 2 c,
--
Giuseppe D'Angelo
--
Std-Proposals mailing list
Std-Proposals@lists.isocpp.org
https://lists.isocpp.org/mailman/listinfo.cgi/std-proposals