# group()
[Adaptors, Lambdas]

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.

Examples:

       void foo(int, int);
       int bar(int);
       // argument binding ...
       sigc::group(&foo,10,sigc::_1)(20); //fixes the first argument and calls foo(10,20)
       sigc::group(&foo,sigc::_1,30)(40); //fixes the second argument and calls foo(40,30)
       // argument reordering ...
       sigc::group(&foo,sigc::_2,sigc::_1)(1,2); //calls foo(2,1)
       // argument hiding ...
       sigc::group(&foo,sigc::_1,sigc::_2)(1,2,3); //calls foo(1,2)
       // functor composition ...
       sigc::group(&foo,sigc::_1,sigc::group(&bar,sigc::_2))(1,2); //calls foo(1,bar(2))
       // algebraic expressions ...
       sigc::group(&foo,sigc::_1*sigc::_2,sigc::_1/sigc::_2)(6,3); //calls foo(6*3,6/3)

The functor sigc::group() returns can be passed into sigc::signal::connect() directly.

Example:

       sigc::signal<void,int,int> some_signal;
       void foo(int);
       some_signal.connect(sigc::group(&foo,sigc::_2));

Like in sigc::bind(), you can bind references to functors by passing the objects through the sigc::ref() helper function.

Example:

       int some_int;
       sigc::signal<void> some_signal;
       void foo(int&);
       some_signal.connect(sigc::group(&foo,sigc::ref(some_int)));

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.

Example:

       struct bar : public sigc::trackable {} some_bar;
       sigc::signal<void> some_signal;
       void foo(bar&);
       some_signal.connect(sigc::group(&foo,sigc::ref(some_bar)));
         // disconnected automatically if some_bar goes out of scope

,