Hello Bjorn,<br><br>Thanks for such a quick help. I works now.<br><br>Can you please further explain the usage of var and constant . <br>in the expression<br>if_(_1 &lt; 24.000001 &amp;&amp; _1 &gt; 23.999999)[ cout &lt;&lt;&quot;Bingo:&lt;&quot;&lt;&lt;_1&lt;&lt;&quot;&gt;&quot;]) 
<br>I understand &quot;Bingo:&lt;&quot; is evaluated immediately, why not &quot;&gt;&quot;, which is not a lambda expression either, is not <br>evaluated along.<br><br>Forgive me if this question seems stupid, but I am new to Lambda, fascinated by its power, but convoluted by its mechanism yet.
<br><br>Thanks.<br> <br>-----Original Message-----<br>From: tom gee [mailto:<a onclick="return top.js.OpenExtLink(window,event,this)" href="mailto:rockonedge@gmail.com">rockonedge@gmail.com</a>]<br>Subject: [Boost-users] A question about boost::lambda::if_ behavior
<br><br>&gt; Can anyone please explain this code:<br>[snip]<br><br>The problem is that the expression std::cout &lt;&lt; constant(&quot;Bingo:&lt;&quot;) is<br>evaluated immediately. Why? Because it's not a lambda expression. You have
<br>two options that will help you turn your if-branch into a lambda expression;<br>either use boost::lambda::var or boost::lambda::constant.<br><br>Using boost::lambda::var:<br><br> &nbsp;std::for_each(setFinalVal.begin(),setFinalVal.end
(),<br> &nbsp; &nbsp;(std::cout &lt;&lt; _1 &lt;&lt; &quot; &quot;, if_(_1 &lt; 24.000001 &amp;&amp; _1 &gt; 23.999999)<br> &nbsp; &nbsp; &nbsp;[var(std::cout) &lt;&lt; &quot;Bingo:&lt;&quot; &lt;&lt; _1 &lt;&lt; &quot;&gt;&quot;]));<br><br>Using boost::lambda::constant:
<br><br> &nbsp;std::for_each(setFinalVal.begin(),setFinalVal.end(),<br> &nbsp; &nbsp;(std::cout &lt;&lt; _1 &lt;&lt; &quot; &quot;, if_(_1 &lt; 24.000001 &amp;&amp; _1 &gt; 23.999999)<br> &nbsp; &nbsp; &nbsp;[std::cout &lt;&lt; constant(&quot;Bingo:&lt;&quot;) &lt;&lt; _1 &lt;&lt; &quot;&gt;&quot;]));
<br><br><br>Cheers,<br>Bjorn Karlsson