Hello Bjorn,

Thanks for such a quick help. I works now.

Can you please further explain the usage of var and constant .
in the expression
if_(_1 < 24.000001 && _1 > 23.999999)[ cout <<"Bingo:<"<<_1<<">"])
I understand "Bingo:<" is evaluated immediately, why not ">", which is not a lambda expression either, is not
evaluated along.

Forgive me if this question seems stupid, but I am new to Lambda, fascinated by its power, but convoluted by its mechanism yet.

Thanks.

-----Original Message-----
From: tom gee [mailto:rockonedge@gmail.com]
Subject: [Boost-users] A question about boost::lambda::if_ behavior

> Can anyone please explain this code:
[snip]

The problem is that the expression std::cout << constant("Bingo:<") is
evaluated immediately. Why? Because it's not a lambda expression. You have
two options that will help you turn your if-branch into a lambda expression;
either use boost::lambda::var or boost::lambda::constant.

Using boost::lambda::var:

 std::for_each(setFinalVal.begin(),setFinalVal.end (),
   (std::cout << _1 << " ", if_(_1 < 24.000001 && _1 > 23.999999)
     [var(std::cout) << "Bingo:<" << _1 << ">"]));

Using boost::lambda::constant:

 std::for_each(setFinalVal.begin(),setFinalVal.end(),
   (std::cout << _1 << " ", if_(_1 < 24.000001 && _1 > 23.999999)
     [std::cout << constant("Bingo:<") << _1 << ">"]));


Cheers,
Bjorn Karlsson