Lambdas have indeterminate type, so you can't know which type will one have. Obviously, the lambda you defined won't be of type bool (it may return a bool, but it's not one), so you would do this instead:
struct foo{
static int faa(int x);
};
int foo::faa(int x){
auto isCon = []()->bool {
return true;
};
return isCon();
}
Here, the auto
keyword tells the compiler to deduce the type for you. The ->bool
expression tells the compiler that the lambda will return a bool.
However, your foo::faa()
function returns an int, so a cast may ocurr because your lambda may return a bool (which has nothing to do with the question, but watch out).