Boost logo

Boost Users :

Subject: [Boost-users] How to use boost::function with boost::phoenix?
From: Jens Mueller (jens.k.mueller_at_[hidden])
Date: 2010-05-01 05:18:34


Hi,

I'm trying out boost:phoenix. Until now I used boost::lambda. I have code
written using boost::lambda that returns a boost::function. E.g.

boost::function<float(float)> flog() {
    using namespace boost::lambda;
    return bind(static_cast<float(*)(float)>(std::log), _1);
}

And with boost::lambda I can reuse the boost::function like this

boost::function<float(float)> func = -bind(flog(), _1);

to build bigger blocks.

But I cannot make it work with boost::phoenix.

boost::function<float(float)> func = -bind(flog(), arg1);

does not compile.

How do I use a boost::function within phoenix? Or what do I need to return
instead of a boost::function to reuse it in phoenix? Basically I want to
build more complex functions out of simple ones which are returned by some
function to hide the internals of the function.
I'm using Boost version 1.41.0 and g++ (Debian 4.3.2-1.1) 4.3.2.

Jens


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