template<class T_functor>
struct sigc::adapts< T_functor >
Base type for adaptors.
sigc::adapts wraps adaptors, functors, function pointers and class methods. It contains a single member functor which is always a sigc::adaptor_base. The typedef adaptor_type defines the exact type that is used to store the adaptor, functor, function pointer or class method passed into the constructor. It differs from T_functor unless T_functor inherits from sigc::adaptor_base.
- Example of a simple adaptor:
namespace my_ns
{
template <class T_functor>
{
template <class T_arg1=void, class T_arg2=void>
struct deduce_result_type
result_type
operator()() const;
template <class T_arg1>
operator()(T_arg1 _A_arg1) const;
template <class T_arg1, class T_arg2>
operator()(T_arg1 _A_arg1, T_arg2 _A_arg2) const;
explicit my_adaptor(const T_functor& _A_functor)
};
}
{
template <class T_functor>
struct visitor<my_ns::my_adaptor<T_functor> >
{
template <class T_action>
static void do_visit_each(const T_action& _A_action,
const my_ns::my_adaptor<T_functor>& _A_target)
{
}
};
}
If you implement your own adaptor, you must also provide your specialization of sigc::visitor<>::do_visit_each<>() that will forward the call to the functor(s) your adapter is wrapping. Otherwise, pointers stored within the functor won't be invalidated when a sigc::trackable object is destroyed and you can end up executing callbacks on destroyed objects.
Your specialization of sigc::visitor<> must be in namespace sigc.