I am looking for pointers on how to use boost to implement a set of
template classes/helper functions which can be used for deferred
function/method call forwarding.
Here's an example of illustrating what I wish to accomplish.
I can live with restictions on the function argument types.
//Define a template type which can capture arguments of any (or
most) functions. I believe boost tuple could suit my requirements.
//Define a template helper function save_args which constructs a
arguments tuple based on the signature of the function passed
as the first argument.
e.g .
R f(T1, T2, T3);
boost:tuple
"vivek_arora" wrote:
I am looking for pointers on how to use boost to implement a set of template classes/helper functions which can be used for deferred function/method call forwarding.
Here's an example of illustrating what I wish to accomplish. I can live with restictions on the function argument types.
//Define a template type which can capture arguments of any (or most) functions. I believe boost tuple could suit my requirements. //Define a template helper function save_args which constructs a arguments tuple based on the signature of the function passed as the first argument.
e.g . R f(T1, T2, T3); boost:tuple
args = save_args(f, t1, t2, t3); //Don't want to explicitly specify types like save_args (t1,t2,t3) //Define another template helper function call_with_args which given another function "g" with a signature conforming with "f" and the argument tuple invokes "g"
e.g. R g(T1, T2, T3) //This should call g(args.get<0>, args.get<1>, args.get<2>) call_with_args(g, args);
Could someone provide ideas, pointers/sample code for implementing save_args, call_with_args helper template functions.
For the latter, see http://lists.boost.org/MailArchives/boost/msg43867.php HTH, Aleksey
Just a comment.
If i resume your need, you are looking for a way to dispatch polymorphic commands known at design time (not run-time).
vivek_arora
participants (3)
-
Aleksey Gurtovoy
-
Alexandre Carsac
-
vivek_arora