The definition of a Callback Wrapper (functor) is shown below:
template <typename Signature> class functor : public detail::get_functor_impl < boost::function_traits<Signature>::arity, Signature >::type { ... }
This is an implementation detail, and usually not required to use the dispatcher library.
detail::get_functor_impl< int Arity, Signature >
is a template facility which allows the functor client to define which
base class it derives from. There are six (6) different functor implementations,
dependent on the number of arguments provided in the signature. This
technique is called parametric base type declaraion, which allows the
compiler to choose the appropriate base class depending on template
parameters. |
The functor can be used in the following example:
boost::dispatch::functor<void()> f; boost::dispatch::functor<int (std::string, double)> g; boost::dispatch::functor<double (my_type, my_other_type, int)> h;
The functor wraps a Boost.Function
function which by default is bound to functor::default_function
that throws a boost::dispatch::unregistered_handler
in case a functor is not initialized but invoked.
See discussion on referencing indexes without associated callbacks that throw an boost::dispatch::unregistered_handler. |
Copyright © 2006 ,2007 Dean Michael Berris |