Boost logo

Boost Users :

From: Arnaldur Gylfason (arnaldur.gylfason_at_[hidden])
Date: 2006-10-19 07:43:52


>You could do it using expression templates. It should be quite easy to
>do and very efficient if you aren't going to need to do type-erasure.

Thanks for the response. I thought about it but I'm not so sure this would
solve it.
I have to generate the expression in steps and the corresponding types are
based on runtime parameters so they are not known at compile time.
Anyway boost::lambda is based on expression templates so I would like to
use that instead of duplicating it.

cheers

Arnaldur

"Felipe Magno de Almeida" <felipe.m.almeida_at_[hidden]>
Sent by: boost-users-bounces_at_[hidden]
18.10.2006 19:45
Please respond to
boost-users_at_[hidden]

To
boost-users_at_[hidden]
cc

Subject
Re: [Boost-users] creating lambda expressions incrementally

On 10/17/06, Arnaldur Gylfason <arnaldur.gylfason_at_[hidden]> wrote:
>
> Hi,
>
> 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 typeof seems to provide a solution though. I was just trying it and
it
> seems to work!
> Am I on the right track or am I overlooking something? If anyone knows a
> better solution please tell me!

You could do it using expression templates. It should be quite easy to
do and very efficient if you aren't going to need to do type-erasure.

>
> cheers
>
> Arnaldur Gylfason

-- 
Felipe Magno de Almeida
_______________________________________________
Boost-users mailing list
Boost-users_at_[hidden]
http://lists.boost.org/mailman/listinfo.cgi/boost-users


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