How to forward to a list of boost::function?

Hi all, I have a class: template<typename function_type> class function_vector { private: std::vector<boost::function<function_type> > functions; }; I want to write an operator() for this template class that takes all the arguments necessary to invoke a function of type function_type. When called, it should call each function in the functions field. How do I do this? I think Boost.Signals2 does something like this, but I can't work out how it is done. Cheers, -John

AMDG John Ky wrote:
I have a class:
template<typename function_type> class function_vector { private: std::vector<boost::function<function_type> > functions; };
I want to write an operator() for this template class that takes all the arguments necessary to invoke a function of type function_type. When called, it should call each function in the functions field.
How do I do this?
I think Boost.Signals2 does something like this, but I can't work out how it is done.
Signals does it by specializing for every possible arity. In Christ, Steven Watanabe

On Mon, Mar 15, 2010 at 9:59 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
John Ky wrote:
I have a class:
template<typename function_type> class function_vector { private: std::vector<boost::function<function_type> > functions; };
I want to write an operator() for this template class that takes all the arguments necessary to invoke a function of type function_type. When called, it should call each function in the functions field.
How do I do this?
I think Boost.Signals2 does something like this, but I can't work out how it is done.
Signals does it by specializing for every possible arity.
Although you (nor signals) needed to do it that way. Using Boost.Fusion you can have it be all automatic, probably even simplify it more if you need better forwarding with Boost.Functional.Forwarding.

OvermindDL1 wrote:
Signals does it by specializing for every possible arity.
Although you (nor signals) needed to do it that way. Using Boost.Fusion you can have it be all automatic, probably even simplify it more if you need better forwarding with Boost.Functional.Forwarding.
What about specializing function_types::components / parameter types for boost::function (it has member typedefs argN_type, arity), and with that build a perfect forwarding adaptor? Works for me... Cheers, Rutger

Hi OvermindDL1, I'm having trouble finding any information on this (or some of the other alternatives presented here). For example, the following page: http://www.boost.org/doc/libs/1_42_0/libs/fusion/doc/html/fusion/functional.... <http://www.boost.org/doc/libs/1_42_0/libs/fusion/doc/html/fusion/functional.html>links to a broken link: http://www.boost.org/doc/libs/1_42_0/libs/functional/forward/doc/html/index.... <http://www.boost.org/doc/libs/1_42_0/libs/functional/forward/doc/html/index.html>Anywhere I can get to the documentation on this? Cheers, -John On Tue, Mar 16, 2010 at 5:00 PM, OvermindDL1 <overminddl1@gmail.com> wrote:
On Mon, Mar 15, 2010 at 9:59 PM, Steven Watanabe <watanabesj@gmail.com> wrote:
AMDG
John Ky wrote:
I have a class:
template<typename function_type> class function_vector { private: std::vector<boost::function<function_type> > functions; };
I want to write an operator() for this template class that takes all the arguments necessary to invoke a function of type function_type. When called, it should call each function in the functions field.
How do I do this?
I think Boost.Signals2 does something like this, but I can't work out
how
it is done.
Signals does it by specializing for every possible arity.
Although you (nor signals) needed to do it that way. Using Boost.Fusion you can have it be all automatic, probably even simplify it more if you need better forwarding with Boost.Functional.Forwarding. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
John Ky
-
OvermindDL1
-
Rutger ter Borg
-
Steven Watanabe