Boost logo

Boost Users :

Subject: Re: [Boost-users] [Boost::mpl] transforming expression both at compile time and runtime
From: Stefan Strasser (strasser_at_[hidden])
Date: 2010-08-16 11:35:19


Zitat von Noman Javed <noman_bwp_at_[hidden]>:

> Can someone guide me how to transform an expression both at compile
> time and at
> runtime? I explain by an example
>
> Suppose I want to transform the following expression like that
> foo(f,other(g,bar)) --> other(g,foo(f,bar)) where bar is an Array
> and the "foo"
> and "other" are the higher order functions.
>
> I can write the metafunction for transforming the type of the
> expression i.e from
> Foo<F, Other<G, Array> > --> Other<G, Foo<F, Array> >
>
> I want to execute this expression in the following way
> Array result = foo(f, other(g, bar)) where within the body of the operator=
> overload of the Array class I have the function transform to transform this
> expression as said above.

if I understand you correctly you want to pass a function object to
operator= and transform it?
then your C++ syntax would be:

Array result = bind(foo,f,bind(other,g,bar));

if so, I'm not aware of any way to "extract the curry" out of a bind() result.

the functional stuff in Boost.Fusion (fused function objects) might be
helpful in building such a bind().

joel, has there been an attempt to make Fusion and Bind work together
in this way?
the result of a bind() could be expressed as a fused function object
plus a fusion sequence. but bind() seems to store the arguments in its
own argument list type, and doesn't expose it.


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