Boost logo

Boost Users :

From: Bjorn.Karlsson_at_[hidden]
Date: 2005-09-22 06:01:49


From: tom gee [mailto:rockonedge_at_[hidden]]

> 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.

Actually it is a lambda expression! The reason is the preceding streaming of
_1, which implicitly marks the expression as a lambda expression. So,
std::cout << "Bingo:<" is not a lambda expression, and is thus evaluated
immediately. The last part of the expression is a lambda expression, _1 <<
">" (or rather std::cout << _1 << ">"), but it won't be invoked.

See http://tinyurl.com/7jq3v for details on how to use constant and var.

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

The question isn't stupid, and you're more than welcome to keep asking. And
I agree that Boost.Lambda's power is fascinating.

Bjorn Karlsson


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net