In some cases, a class may want to receive multiple signals of the same signature. For example, the following class could receive void() signals both through operator() and through AltInput:
class Signal2VoidInputs : public signals::consumer<Signal2VoidInputs> { public: Signal2VoidInputs() : result(0) {}; void operator()() { result++; } void AltInput() { result+=10; } int GetResult() { return result; } private: int result; }; // end class Signal2VoidInputs
The following example shows how to connect signals to all of the above slots. For the class Signal2VoidInputs, this is accomplished using the bind_mem_fn function:
signals::storage<void()> banger; Signal2VoidInputs inputs; banger | inputs // this will connect to operator()() | signals::bind_mem_fn(&Signal2VoidInputs::AltInput, inputs); banger(); BOOST_CHECK_EQUAL(inputs.GetResult(), 11);