Boost logo

Boost Users :

From: Scott Lamb (slamb_at_[hidden])
Date: 2004-03-08 18:23:26


On Mar 8, 2004, at 5:05 PM, George Diamantopoulos wrote:

> Hi everyone,
>
> I was trying the other day to "save" a boost::lambda::bind I made so I
> can reuse it a few lines later.
>
> I tried saving to a bind_t which seems to be the return type of bind()
> but I was getting some compilation errors. If I recall correctly, it
> wouldn't find bind_t in any of boost:: or boost::lambda::

I've never used boost::lambda, but boost::bind returns an unspecified
type.

> Anyone knows if/how it's possible?

Yes; I regularly do this. Though the type is unspecified, it is
assignable to a boost::function.

> Just in case you're don't know what I mean, here's a code snippet:
>
> bind_t myExpression = bind(&Object::method, this);
> f(myExpression);
> g(myExpression);

Try something like:

     boost::function<void ()> myFunction = bind(&Object::method, this);
     f(myFunction);
     g(myFunction);

and take a look at
<http://www.boost.org/libs/bind/bind.html#with_boost_function>

Scott


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