|
Boost Users : |
From: Arkadiy Vertleyb (vertleyb_at_[hidden])
Date: 2006-10-18 15:35:13
"Arnaldur Gylfason" <arnaldur.gylfason_at_[hidden]> wrote
>I´m writing a simple expression parser in boost::spirit that can parse a
>string like "_1 + _2" or "log(_1)" and return a function object that does
>just that.
>I used boost::lamda for that and return it as boost::function object.
>Now I want to parse compositions like "sqrt(_1*_1 + _2*_2)" or "(_1 +
>_2)*_2" etc. It is easy to parse this of course but I have to create the
>corresponding function incrementally (in a loop or recursively)
>and that means I have to keep incremental lambdas until the whole
>expression has been created.
>I can not store them as boost::function since they do not work with lambda
>operator overloading (apart from the fact that it would be too costly).
>I need a lambda type for these intermediate lambda objects. I guess the
>auto type specifier would solve this but when will that be available I
>wonder?
The upcoming version of Boost, 1.34, will contain the Boost.Typeof library
that will provide the BOOST_TYPEOF and BOOST_AUTO macros to emulate this
facilities. The current snapshot of 1.34 can be obtained from Boost CVS.
>The typeof seems to provide a solution though. I was just trying it and it
>seems to work!
For the Boost.Typeof library to handle lambda expressions, on the platforms
where typeof is not natively supported, Boost.Lambda templates need to be
registered. The Boost.Typeof documentation describes this using
Boost.Lambda as an example. Generally it's up to maintainers of Lambda
library to decide if to provide the typeof support, and, to the best of my
knowledge, it won't happen in 1.34 :(
This registration of the lambda templates can be also done externally
(again, see the typeof docs on how to do this), but this has to be kept
in-sync with the Lambda templates.
The two Boost libraries to support typeof in 1.34 will be spirit and
xpressive.
Regards,
Arkadiy
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