Reputation: 19
This my code:
std::thread t([](){
int ret = func();
if (ret != 0){
return false;
}
});
t.detach();
As this code, compiler deduce the lambda return value type is bool, so when ret==0, the lambda has not a return value, then program is crash. Add return true can solve this problem, I want to now why?
I want to know, lambda return behavior when used in thread.
Upvotes: 0
Views: 99