Is it possible to automatically implement the number of variables captured by lambda when accessed by value or by reference? Is it also possible to decipher their types? For example, suppose this piece of code:
int a = 47;
int b = 48;
long long c = 49;
auto f1 = [=](){ return a + b; };
auto f2 = [=](){ return a + b + c; };
Is it possible to have a function with a name count_argsthat returns 2in the line and 3in the next line if called as shown below?
std::cout << count_args( f1 ) << "\n" << count_args( f2 );
source
share