Boost logo

Boost :

From: Noah Stein (noah_at_[hidden])
Date: 2002-03-20 12:36:37


> -----Original Message-----
> From: boost-admin_at_[hidden] [mailto:boost-admin_at_[hidden]]On
> Behalf Of Gary Powell
> Sent: Wednesday, March 20, 2002 8:44 AM
> To: boost_at_[hidden]
> Subject: RE: [boost] Phoenix: A Lambda Lib. alternative
>
>
>
> // Print all odd contents of an stl container c
> for_each(c.begin(), c.end(),
> if_(is_odd(arg1))
> [
> cout << arg1 << ' '
> ]
> );
>
> Notice the if_ syntax.
> ----------------------------------------------------------
> Hey! Cool reuse of "[]"!
>
> What about using it for "for_" et.al.????
>
> for_each(c.begin(), c.end(),
> for_(var(i)=_1[0], var(i) != _1[LAST], ++var(i))
> [
> ]
> )
>
> -Who hasn't seen this much work being done on other Lambda stuff
> in at least
> a year.-
> -Gary-

Joel's done the for loop also. I've been hanging out on the Spirit mail
list for a while, and he's got some neat stuff. I'd suggest checking it
out. For example, his if/else construct looks pretty nice:

        for_each(c.begin(), c.end(),
                if_(is_odd(arg1))
                        [
                                cout << "odd" << ' '
                        ]
                .else_
                        [
                                cout << "even" << ' '
                        ]
                );

If you check the links on his page (which I've copied down below just to
make it easy :), he has done some really neat stuff with the library. The
closures, which Joel didn't really get into in his message, are also an
interesting and useful feature.

> preliminary draft docs:
>
> http://spirit.sourceforge.net/dl_more/phoenix_manual.txt
>
> v0.9 alpha:
>
> http://spirit.sourceforge.net/dl_more/phoenix_v0_9.zip

-- Noah


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