I am trying make ternary operator work with lambda. Following is the logic that I want to cast into a ternary operation
if (boolean_condition_var == false) {
RandomMethod();
}
// From here some logic to execute
int i = 0;
// blah blah logic
Following is how I am trying to make it work after reading through this link.
boolean_condition_var == false ? RandomMethod() : std::function<void(void)>([this](){
// execute some logic here
int i = 0;
//blah blah logic
});
But I am getting the following error:
Issue:
error: left operand to ? is void, but right operand is of type 'std::function<void ()>'
boolean_condition_var == false ? RandomMethod() : std::function<void(void)>([this](){ int i = 0; });
Question:
How can I pass a lambda into the second clause of my ternary operator?