
"fmingu" <fmingu@163.com> wrote in message news:31100020.905591247202195143.JavaMail.coremail@bj163app94.163.com...
After your advice,I wrote the following test program: int main(int argc, char *argv[]) { int nnumber=7; int switchvalue=1; if_then_else(var(nnumber)==6, var(switchvalue)=3 ,var(switchvalue)=30); std::cout<<" the nnumber is "<<nnumber<<" and switchvalue is "<<switchvalue<<"\n"; system("PAUSE"); return 0; } and the result is: the nnumber is 7 and and switchvalue is 1 Even if_then_else(var(nnumber)==6, var(switchvalue)=constant(3) ,var(switchvalue)=constant(30)); get the same result.
the value in the lambda expression did not saved. Can you tell me why?
if_then_else only creates and returns a lambda function object.
And How can I correct it?
You need to apply it (note invoking the fn call operator): if_then_else(var(nnumber)==6, var(switchvalue)=3 ,var(switchvalue)=30)(); HTH / Johan