Boost logo

Boost Users :

From: Edward Diener (eldiener_at_[hidden])
Date: 2006-10-02 07:51:04


Johan Torp wrote:
> I often tend to have interfaces which take a boost::function<void()>
> that is to be called when an event occurs. Quite often I need make two
> separate function calls as response to one event. In these cases I
> usually solve the problem using the following technique:
>
> void foo();
> void bar();
>
> void call_two(const boost::function<void ()>& one, const
> boost::function<void ()>& two)
> { one(); two(); }
>
> boost::function<void ()> on_event = boost::bind(&call_two,
> boost::bind(&foo), boost::bind(&bar));

Why not just use Boost Signals to have a single signal just call your
two different slots of foo and bar ? It seems you are unnecessarily
trying to re-invent a wheel which has already been re-invented by the
signals library.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net