This question already has an answer here:
- How is std::function implemented? 4 answers
This lambda works and returns correct value when invoked, When i look at the return value, this lambda should be stored in an int variable How is it possible to store this in a std::function
#include <iostream>
#include <functional>
using namespace std;
int main(){
function<int(void)> f = [](){
int some_variable = 10;
// do some calculation
return some_variable;
};
cout<<f();
}
What goes behind the hood to make it work the way it works
Aucun commentaire:
Enregistrer un commentaire