Boost logo

Boost :

From: Dave Abrahams (abrahams_at_[hidden])
Date: 2000-03-18 00:22:46


on 3/17/00 10:53 PM, Greg Colvin at gcolvin_at_[hidden] wrote:

> Aha. But lots of operators (29 by my count) have higher precedence
> than /, so if it's precedence you want then you might overload []
> boost::lambda[ std::cout << ", " << boost::free1 ]

That one is evaluated like this:

operator[](
    boost::lambda,
    operator<<(
        operator<<(std::cout, ", "),
        boost::free1)
    )
}

Innermost expressions first. To use op[], you'd have to write this:

    boost::lambda[ std::cout ] << ", " << boost::free1

But I'm not so sure lambda/ is such a hot idea after all, since in this
case:

    boost::lambda/ x + y * z

is the same as

    (boost::lambda/ x) + (y * z)

and the y * z term will be evaluated before it gets to interact with
boost::lambda.

Is there any way to salvage this approach? I don't see one :(

-Dave


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk