libsigc++: compose()

libsigc++ 2.12.2

Classes | Functions
compose()
Adaptors

sigc::compose() combines two or three arbitrary functors. More...

## Classes
struct | sigc::compose1_functor< T_setter, T_getter >
| Adaptor that combines two functors. More...
struct | sigc::compose2_functor< T_setter, T_getter1, T_getter2 >
| Adaptor that combines three functors. More...

## Functions
template<class T_setter, class T_getter>
compose1_functor< T_setter, T_getter > | sigc::compose (const T_setter & _A_setter, const T_getter & _A_getter)
| Creates an adaptor of type sigc::compose1_functor which combines two functors.
template<class T_setter, class T_getter1, class T_getter2>
compose2_functor< T_setter, T_getter1, T_getter2 > | sigc::compose (const T_setter & _A_setter, const T_getter1 & _A_getter1, const T_getter2 & _A_getter2)
| Creates an adaptor of type sigc::compose2_functor which combines three functors.

## Detailed Description

sigc::compose() combines two or three arbitrary functors.

On invokation, parameters are passed on to one or two getter functor(s). The return value(s) are then passed on to the setter function.

Examples:
  float square_root(float a) { return sqrtf(a); }
  float sum(float a, float b) { return a+b; }
  std::cout << sigc::compose(&square_root, &sum)(9, 16); // calls square_root(sum(3,6))
  std::cout << sigc::compose(&sum, &square_root, &square_root)(9); // calls sum(square_root(9), square_root(9))
  sum
  _Tp sum() const
  std::cout
  ostream cout
  sigc::compose
  compose1_functor< T_setter, T_getter > compose(const T_setter &_A_setter, const T_getter &_A_getter)
  Creates an adaptor of type sigc::compose1_functor which combines two functors.
  Definition compose.h:288

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

Example:
  sigc::signal<float,float,float> some_signal;
  some_signal.connect(sigc::compose(&square_root, &sum));
  sigc::signal7::connect
  iterator connect(const slot_type &slot_)
  Add a slot to the list of slots.
  Definition signal.h:3911
  sigc::signal
  Convenience wrapper for the numbered sigc::signal# templates.
  Definition signal.h:4055

## Function Documentation

## ◆ compose() [1/2]

template <class T_setter, class T_getter>

compose1_functor< T_setter, T_getter > sigc::compose | ( | const T_setter & | _A_setter,
|  | const T_getter & | _A_getter )
| inline

Creates an adaptor of type sigc::compose1_functor which combines two functors.

Parameters

  _A_setter | Functor that receives the return value of the invokation of _A_getter.
  _A_getter | Functor to invoke from operator()().

Returns
  Adaptor that executes _A_setter with the value returned from invokation of _A_getter.

## ◆ compose() [2/2]

template <class T_setter, class T_getter1, class T_getter2>

compose2_functor< T_setter, T_getter1, T_getter2 > sigc::compose | ( | const T_setter & | _A_setter,
|  | const T_getter1 & | _A_getter1,
|  | const T_getter2 & | _A_getter2 )
| inline

Creates an adaptor of type sigc::compose2_functor which combines three functors.

Parameters

  _A_setter | Functor that receives the return values of the invokation of _A_getter1 and _A_getter2.
  _A_getter1 | Functor to invoke from operator()().
  _A_getter2 | Functor to invoke from operator()().

Returns
  Adaptor that executes _A_setter with the values return from invokation of _A_getter1 and _A_getter2.