libsigc++: Functors

Functors are copyable types that define operator()(). More...

Modules

 Slots
 Slots are type-safe representations of callback methods and functions.

 
 mem_fun()
 mem_fun() Creates a functor from a pointer to a method.

 
 ptr_fun()
 ptr_fun() creates a functor from a pointer to a function.

 

Classes

struct  sigc::functor_trait< T_functor >
 Trait that specifies the appropriate functor type of any callable type. More...

 
struct  sigc::visitor< T_functor >
 sigc::visitor<T_functor>::do_visit_each() performs a functor on each of the targets of a functor. More...

 

Functions

template<typename T_action , typename T_functor >
void sigc::visit_each (const T_action& action, const T_functor& functor)
 This function performs a functor on each of the targets of a functor. More...

 
template<typename T_action , typename T_functor >
void sigc::visit_each_trackable (const T_action& action, const T_functor& functor)
 This function performs a functor on each of the targets of a functor limited to a restricted type. More...

 

Detailed Description

Functors are copyable types that define operator()().

Types that define operator()() overloads with different return types are referred to as multi-type functors. Multi-type functors are only partially supported in libsigc++.

Closures are functors that store all information needed to invoke a callback from operator()().

Adaptors are functors that alter the signature of a functor's operator()().

libsigc++ defines numerous functors, closures and adaptors. Since libsigc++ is a callback library, most functors are also closures. The documentation doesn't distinguish between functors and closures.

The basic functor types libsigc++ provides are created with ptr_fun() and mem_fun() and can be converted into slots implicitly. The set of adaptors that ships with libsigc++ is documented in the Adaptors module.

Function Documentation

template <typename T_action , typename T_functor >
void sigc::visit_each ( const T_action &  action,
const T_functor &  functor 
)

This function performs a functor on each of the targets of a functor.

template <typename T_action , typename T_functor >
void sigc::visit_each_trackable ( const T_action &  action,
const T_functor &  functor 
)

This function performs a functor on each of the targets of a functor limited to a restricted type.

It is currently used only to call slot_do_bind and slot_do_unbind only on trackable-derived arguments of the functors, like a compile-time version of if(dynamic_cast<trackable*)(& arg) { slot_do_unbind(arg); } This also depends on do_visit_each() method overloads for limit_trackable_target<slot_do_bind/slot_do_unbind> parameters in the visitor<slot> template specialization. TODO: Remove the need for slot_do_bind/slot_do_unbind, limit_trackable_target, and visit_each_trackable() by just using a constexpr_if (previously known as static_if) if that ends up in C++17.