[bind] Specifying bind types
I have a situation where I need to be able to specify the type of
object that will be created by an invocation of bind():
template<typename F>
class Callback {
public:
Callback(F func) ...
}
template
Sebastian Redl wrote:
David A. Greene wrote:
What's the best way to do this? typeof?
One option is boost::function, but that would require a bit of refactoring, most likely, and would impose a runtime overhead.
Can you explain how boost::function would help here? boost::function doesn't handle argument binding. Are you suggesting that the Function argument to the Callback template would be a boost::function type? I'm not as concerned about the runtime overhead at the moment but it may become an issue later. -Dave
David A. Greene wrote:
Sebastian Redl wrote:
David A. Greene wrote:
What's the best way to do this? typeof?
One option is boost::function, but that would require a bit of refactoring, most likely, and would impose a runtime overhead.
Can you explain how boost::function would help here?
Well, you didn't provide much details, but
template<typename F> class Callback { public: Callback(F func) ... }
template
class OneMoreArgCallback : public Callback { public: OneMoreArgCallback(F func, Arg arg) : Callback(boost::bind(func, arg, _1)) {}; }
depending on the contents of the ... in Callback, it might be possible to replace the whole Callback hierarchy with boost::function.
participants (3)
-
David A. Greene
-
Peter Dimov
-
Sebastian Redl