libsigc++  3.6.0
Classes | Functions
compose()

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<typename T_setter , typename T_getter >
compose1_functor< T_setter, T_getter > sigc::compose (const T_setter & setter, const T_getter & getter)
 Creates an adaptor of type sigc::compose1_functor which combines two functors. More...
 
template<typename T_setter , typename T_getter1 , typename T_getter2 >
compose2_functor< T_setter, T_getter1, T_getter2 > sigc::compose (const T_setter & setter, const T_getter1 & getter1, const T_getter2 & getter2)
 Creates an adaptor of type sigc::compose2_functor which combines three functors. More...
 

Detailed Description

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

On invocation, 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))
_Tp sum() const
ostream cout
compose1_functor< T_setter, T_getter > compose(const T_setter &setter, const T_getter &getter)
Creates an adaptor of type sigc::compose1_functor which combines two functors.
Definition: compose.h:171

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

Example:
sigc::signal(float(float, float)> some_signal;
some_signal.connect(sigc::compose(&square_root, &sum));

Function Documentation

◆ compose() [1/2]

template <typename T_setter , typename T_getter >
compose1_functor<T_setter, T_getter> sigc::compose ( const T_setter &  setter,
const T_getter &  getter 
)
inline

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

Parameters
setterFunctor that receives the return value of the invocation of getter.
getterFunctor to invoke from operator()().
Returns
Adaptor that executes setter with the value returned from invocation of getter.

◆ compose() [2/2]

template <typename T_setter , typename T_getter1 , typename T_getter2 >
compose2_functor<T_setter, T_getter1, T_getter2> sigc::compose ( const T_setter &  setter,
const T_getter1 &  getter1,
const T_getter2 &  getter2 
)
inline

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

Parameters
setterFunctor that receives the return values of the invocation of getter1 and getter2.
getter1Functor to invoke from operator()().
getter2Functor to invoke from operator()().
Returns
Adaptor that executes setter with the values return from invocation of getter1 and getter2.