|
libsigc++ 2.12.0
|
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() is used to convert a pointer to a function to a functor. | |
Classes | |
| class | sigc::can_deduce_result_type_with_decltype< T_functor > |
| Helper class, to determine if decltype() can deduce the result type of a functor. More... | |
| struct | sigc::functor_base |
| A hint to the compiler. More... | |
| struct | sigc::functor_trait< T_functor, I_derives_functor_base, I_can_use_decltype > |
| Trait that specifies the return type of any 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... | |
Macros | |
| #define | SIGC_FUNCTOR_TRAIT(T_functor, T_return) |
| Helper macro, if you want to mix user-defined and third party functors with libsigc++. More... | |
| #define | SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE |
| Helper macro, if you want to mix user-defined and third party functors with libsigc++. More... | |
| #define | SIGC_FUNCTORS_HAVE_RESULT_TYPE |
| Helper macro, if you want to mix user-defined and third party functors with libsigc++. More... | |
Functions | |
| template<class T_action , class T_functor > | |
| void | sigc::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. More... | |
| template<class T_type , class T_action , class T_functor > | |
| void | sigc::visit_each_type (const T_action & _A_action, const T_functor & _A_functor) |
| This function performs a functor on each of the targets of a functor limited to a restricted type. More... | |
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.
If you want to mix user-defined and third party functors with libsigc++, and you want them to be implicitly convertible into slots, libsigc++ must know the result type of your functors. There are different ways to achieve that.
typedef T_return result_type; in the class definition.If all these ways to deduce the result type fail, void is assumed.
With libsigc++ versions before 2.6, the macro SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE activated the test with decltype(). That macro is now unneccesary and deprecated.
| #define SIGC_FUNCTOR_TRAIT | ( | T_functor, | |
| T_return | |||
| ) |
Helper macro, if you want to mix user-defined and third party functors with libsigc++.
If you want to mix functors not derived from sigc::functor_base with libsigc++, and these functors don't define result_type, use this macro inside namespace sigc to expose the return type of the functors like so:
| #define SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE |
Helper macro, if you want to mix user-defined and third party functors with libsigc++.
If you want to mix functors not derived from sigc::functor_base with libsigc++, and your compiler can deduce the result type of the functor with the C++11 keyword decltype, use this macro inside namespace sigc like so:
Functors with overloaded operator()() are not supported.
| #define SIGC_FUNCTORS_HAVE_RESULT_TYPE |
Helper macro, if you want to mix user-defined and third party functors with libsigc++.
If you want to mix functors not derived from sigc::functor_base with libsigc++, and these functors define result_type, use this macro inside namespace sigc like so:
| void sigc::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.
| void sigc::visit_each_type | ( | const T_action & | _A_action, |
| const T_functor & | _A_functor | ||
| ) |
This function performs a functor on each of the targets of a functor limited to a restricted type.