Boost logo

Boost Users :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-02-17 21:25:21


David Williams wrote:
> Hi, if I call boost::bind it creates a function object, is that
> correct? So how can I give this function object a name? That is,
> presumably I can have an expression like:
>
> SomeTypeHere myFunc = boost::bind(...);
>
> But what should SomeTypeHere actually be? I've found I can use
> boost::function but would rather not for performance reasons. Any
> other options?

If you want to store it for later use, boost::function<> is your only real
option. In principle, you could write

int f = boost::bind( ... );

and then copy the real type from the error message, but I wouldn't go that
way. :-)

If you just need a temporary named copy, you can introduce a helper function
templatized on the function object type (an algorithm) and pass
boost::bind( ... ) to it. Hopefully in a four years or so the language will
allow us to write

auto f = boost::bind( ... );


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