|
Boost Users : |
From: Johan Torp (johan.torp_at_[hidden])
Date: 2006-10-02 07:30:45
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));
Is there any other way to acheive this, beside having to redeclare and
define a function such as call_two?
It seems quite easy to define something like:
template <typename R1, typename R2>
void nullary_compose boost::function<R1 ()>& one, const
boost::function<R2 ()>& two);
template <typename R1, typename R2, typename R3>
void nullary_compose boost::function<R1 ()>& one, const
boost::function<R2 ()>& two, const boost::function<R3 ()>& three);
...
Is anybody else interested in seeing such templates in boost?
Best Regards,
Johan Torp
-- System Developer TouchTable AB Tel: +46 (0)31 773 68 12 johan.torp_at_[hidden]
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