Hi Frederick,
in a C++ way, compare (equate) calling a lambda with calling a member function.
You have the pointer to the object and the pointer to the member function itself.
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
-----Ursprüngliche Nachricht-----
Von: Frederick Virchanza Gotham via Std-Proposals <std-proposals@lists.isocpp.org>
Gesendet: Fr 14.04.2023 15:19
Betreff: [std-proposals] Function Pointer from Lambda with Captures
An: std-proposals <std-proposals@lists.isocpp.org>;
To invoke a capture lambda, we need two pieces of data:
Datum A: The address of the lambda object
Datum B: The address of the 'operator()' member function
Datum A is a pointer into data memory.
Datum B is a pointer into code memory.