Main Page Groups Namespaces

# bind(), bind_return()
[Adaptors]

Collaboration diagram for bind(), bind_return():

sigc::bind() alters an arbitrary functor by fixing arguments to certain values. More...

## Classes

struct | sigc::bind_functor<0, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<1, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<2, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<3, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<4, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<5, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<6, T_functor, T_bound, nil, nil, nil, nil, nil, nil>
| Adaptor that binds an argument to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, nil, nil, nil, nil, nil, nil >
| Adaptor that binds 1 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, nil, nil, nil, nil, nil >
| Adaptor that binds 2 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, T_type3, nil, nil, nil, nil >
| Adaptor that binds 3 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, nil, nil, nil >
| Adaptor that binds 4 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, nil, nil >
| Adaptor that binds 5 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, nil >
| Adaptor that binds 6 argument(s) to the wrapped functor. More...
struct | sigc::bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, T_type7 >
| Adaptor that binds 7 argument(s) to the wrapped functor. More...
struct | sigc::bind_return_functor<T_return, T_functor>
| Adaptor that fixes the return value of the wrapped functor. More...

## Functions

template<class T_action, int T_loc, class T_functor, class T_bound>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<T_loc, T_functor, T_bound>& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2, class T_type3>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2, T_type3 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_type7>
void | sigc::visit_each (const T_action& _A_action, const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, T_type7 >& _A_target)
| Performs a functor on each of the targets of a functor.
template<int I_location, class T_bound1, class T_functor>
bind_functor < I_location, T_functor, T_bound1 > | sigc::bind (const T_functor& _A_func, T_bound1 _A_b1)
| Creates an adaptor of type sigc::bind_functor which binds the passed argument to the passed functor.
template<class T_type1, class T_functor>
bind_functor<-1, T_functor, T_type1 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1)
| Creates an adaptor of type sigc::bind_functor which fixes the last 1 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2)
| Creates an adaptor of type sigc::bind_functor which fixes the last 2 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_type3, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2, T_type3 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2, T_type3 _A_b3)
| Creates an adaptor of type sigc::bind_functor which fixes the last 3 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_type3, class T_type4, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2, T_type3 _A_b3, T_type4 _A_b4)
| Creates an adaptor of type sigc::bind_functor which fixes the last 4 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2, T_type3 _A_b3, T_type4 _A_b4, T_type5 _A_b5)
| Creates an adaptor of type sigc::bind_functor which fixes the last 5 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2, T_type3 _A_b3, T_type4 _A_b4, T_type5 _A_b5, T_type6 _A_b6)
| Creates an adaptor of type sigc::bind_functor which fixes the last 6 argument(s) of the passed functor.
template<class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_type7, class T_functor>
bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, T_type7 > | sigc::bind (const T_functor& _A_func, T_type1 _A_b1, T_type2 _A_b2, T_type3 _A_b3, T_type4 _A_b4, T_type5 _A_b5, T_type6 _A_b6, T_type7 _A_b7)
| Creates an adaptor of type sigc::bind_functor which fixes the last 7 argument(s) of the passed functor.
template<class T_action, class T_return, class T_functor>
void | sigc::visit_each (const T_action& _A_action, const bind_return_functor<T_return, T_functor>& _A_target)
| Performs a functor on each of the targets of a functor.
template<class T_return, class T_functor>
bind_return_functor < T_return, T_functor > | sigc::bind_return (const T_functor& _A_functor, T_return _A_ret_value)
| Creates an adaptor of type sigc::bind_return_functor which fixes the return value of the passed functor to the passed argument.

## Detailed Description

sigc::bind() alters an arbitrary functor by fixing arguments to certain values.

Up to 7 arguments can be bound at a time. For single argument binding overloads of sigc::bind() are provided that let you specify the zero-based position of the argument to fix with the first template parameter. (A value of `-1` fixes the last argument so sigc::bind<-1>() gives the same result as sigc::bind().) The types of the arguments can optionally be specified if not deduced.

Examples:

         void foo(int, int, int);
         // single argument binding ...
         sigc::bind(&foo,1)(2,3);     //fixes the last (third) argument and calls foo(2,3,1)
         sigc::bind<-1>(&foo,1)(2,3); //same as bind(&foo,1)(2,3) (calls foo(2,3,1))
         sigc::bind<0>(&foo,1)(2,3);  //fixes the first argument and calls foo(1,2,3)
         sigc::bind<1>(&foo,1)(2,3);  //fixes the second argument and calls foo(2,1,3)
         sigc::bind<2>(&foo,1)(2,3);  //fixes the third argument and calls foo(2,3,1)
         // multi argument binding ...
         sigc::bind(&foo,1,2)(3);     //fixes the last two arguments and calls foo(3,1,2)
         sigc::bind(&foo,1,2,3)();    //fixes all three arguments and calls foo(1,2,3)

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

Example:

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

sigc::bind_return() alters an arbitrary functor by fixing its return value to a certain value.

Example:

         void foo();
         std::cout << sigc::bind_return(&foo, 5)(); // calls foo() and returns 5

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::bind(&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 bind 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::bind(&foo,sigc::ref(some_bar)));
           // disconnected automatically if some_bar goes out of scope

For a more powerful version of this functionality see the lambda library adaptor sigc::group() which can bind, hide and reorder arguments arbitrarily. Although sigc::group() is more flexible, sigc::bind() provides a means of binding parameters when then total number of parameters called is variable.

## Function Documentation

template <class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_type7, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, T_type7> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2,
|  | T_type3 | _A_b3,
|  | T_type4 | _A_b4,
|  | T_type5 | _A_b5,
|  | T_type6 | _A_b6,
|  | T_type7 | _A_b7 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 7 argument(s) of the passed functor.

This function overload fixes the last 7 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.
  | _A_b3 | Argument to bind to _A_func.
  | _A_b4 | Argument to bind to _A_func.
  | _A_b5 | Argument to bind to _A_func.
  | _A_b6 | Argument to bind to _A_func.
  | _A_b7 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2,
|  | T_type3 | _A_b3,
|  | T_type4 | _A_b4,
|  | T_type5 | _A_b5,
|  | T_type6 | _A_b6 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 6 argument(s) of the passed functor.

This function overload fixes the last 6 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.
  | _A_b3 | Argument to bind to _A_func.
  | _A_b4 | Argument to bind to _A_func.
  | _A_b5 | Argument to bind to _A_func.
  | _A_b6 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2,
|  | T_type3 | _A_b3,
|  | T_type4 | _A_b4,
|  | T_type5 | _A_b5 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 5 argument(s) of the passed functor.

This function overload fixes the last 5 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.
  | _A_b3 | Argument to bind to _A_func.
  | _A_b4 | Argument to bind to _A_func.
  | _A_b5 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_type2, class T_type3, class T_type4, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2,
|  | T_type3 | _A_b3,
|  | T_type4 | _A_b4 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 4 argument(s) of the passed functor.

This function overload fixes the last 4 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.
  | _A_b3 | Argument to bind to _A_func.
  | _A_b4 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_type2, class T_type3, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2, T_type3> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2,
|  | T_type3 | _A_b3 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 3 argument(s) of the passed functor.

This function overload fixes the last 3 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.
  | _A_b3 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_type2, class T_functor>

bind_functor<-1, T_functor, T_type1, T_type2> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1,
|  | T_type2 | _A_b2 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 2 argument(s) of the passed functor.

This function overload fixes the last 2 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.
  | _A_b2 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_type1, class T_functor>

bind_functor<-1, T_functor, T_type1> sigc::bind | ( | const T_functor & | _A_func,
|  | T_type1 | _A_b1 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which fixes the last 1 argument(s) of the passed functor.

This function overload fixes the last 1 argument(s) of _A_func.

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <int I_location, class T_bound1, class T_functor>

bind_functor<I_location, T_functor, T_bound1> sigc::bind | ( | const T_functor & | _A_func,
|  | T_bound1 | _A_b1 |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_functor which binds the passed argument to the passed functor.

The optional template argument I_location specifies the zero-based position of the argument to be fixed (`-1` stands for the last argument).

Parameters:

  | _A_func | Functor that should be wrapped.
  | _A_b1 | Argument to bind to _A_func.

Returns:
  Adaptor that executes _A_func with the bound argument on invokation.

template <class T_return, class T_functor>

bind_return_functor<T_return, T_functor> sigc::bind_return | ( | const T_functor & | _A_functor,
|  | T_return | _A_ret_value |
| ) |  |  | `[inline]`

Creates an adaptor of type sigc::bind_return_functor which fixes the return value of the passed functor to the passed argument.

Parameters:

  | _A_functor | Functor that should be wrapped.
  | _A_ret_value | Argument to fix the return value of _A_functor to.

Returns:
  Adaptor that executes _A_functor on invokation and returns _A_ret_value.

template <class T_action, class T_return, class T_functor>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_return_functor< T_return, T_functor > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_return_functor performs a functor on the functor and on the object instance stored in the sigc::bind_return_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6, class T_type7>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6, T_type7 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5, class T_type6>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5, T_type6 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4, class T_type5>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4, T_type5 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2, class T_type3, class T_type4>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2, T_type3, T_type4 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2, class T_type3>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2, T_type3 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1, class T_type2>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1, T_type2 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, class T_functor, class T_type1>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor<-1, T_functor, T_type1 > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.

template <class T_action, int T_loc, class T_functor, class T_bound>

void sigc::visit_each | ( | const T_action & | _A_action,
|  | const bind_functor< T_loc, T_functor, T_bound > & | _A_target |
| ) |  |  | `[inline]`

Performs a functor on each of the targets of a functor.

The function overload for sigc::bind_functor performs a functor on the functor and on the object instances stored in the sigc::bind_functor object.