
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( ... );