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 <>
Gesendet: Fr 14.04.2023 17:50
Betreff: Re: [std-proposals] Function Pointer from Lambda with Captures
Anlage: untitled
CC: Giuseppe D‘Angelo <>;

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.

My 2 c,
Giuseppe D'Angelo
Std-Proposals mailing list