libsigc++
2.3.1
|
sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions. More...
sigc::group() alters an arbitrary functor by rebuilding its arguments from one or more lambda expressions.
For each parameter that should be passed to the wrapped functor, one lambda expression has to be passed into group(). Lambda selectors can be used as placeholders for the arguments passed into the new functor. Arguments that don't have a placeholder in one of the lambda expressions are dropped.
If you have a C++11 compiler, a C++11 lambda expression and/or std::bind() is often a good alternative to sigc::group(). Such alternatives are shown in the following examples, marked with the comment //C++11
.
The functor sigc::group() returns can be passed into sigc::signal::connect() directly. A C++11 lambda expression can be passed into sigc::signal::connect() directly, if either it returns void
, or you use SIGC_FUNCTORS_DEDUCE_RESULT_TYPE_WITH_DECLTYPE.
Like in sigc::bind(), you can bind references to functors by passing the objects through the sigc::ref() helper function.
If you bind an object of a sigc::trackable derived type to a functor by reference, a slot assigned to the group adaptor is cleared automatically when the object goes out of scope.
std::bind() and C++11 lambda expressions fail here. If you store a reference to a sigc::trackable derived object in a C++11 lambda expression, and assign this expression to a slot or signal, it will not be disconnected automatically when the object goes out of scope. The previous example can still be rewritten without sigc::group().