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>
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)
{
}
};
}
void visit_each(const T_action &_A_action, const T_functor &_A_functor)
This function performs a functor on each of the targets of a functor.
Definition: visit_each.h:169
The libsigc++ namespace.
Definition: connection.h:24
typename deduce_result_type< T_functor, T_args... >::type deduce_result_t
Definition: deduce_result_type.h:68
Base type for adaptors.
Definition: adaptor_trait.h:387
Deduce the return type of a functor.
Definition: deduce_result_type.h:50
decltype(test< T_functor >()) type
Definition: deduce_result_type.h:64
void result_type
Definition: functor_trait.h:135
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.