On Thu, Feb 26, 2009 at 6:53 PM, Perry, Daniel <PerryD@3dsystems.com> wrote:
AMDG

Perry, Daniel wrote:
> I've been trying to design a function dispatch system and I was
> wondering if the following is possible with the current boost
libraries...
>
> I currently parse json data into an vector of variants, I would like
> to be able to take those variants and invoke an arbitrary boost
> function object with a consistent return type.
>
> Is it possible to determine the function argument types, get the typed

> value from the proper index in the array of variants, and call the
> function with arguments?
>
> This sounds like something the boost fusion library might be able to
> do, but I can't find any example code using the library to see if this

> is the right fit for the capabilities of the library or if what I'm
> looking to do is not possible without tons of boiler plate.

Is apply_visitor what you are looking for?
http://www.boost.org/doc/html/boost/apply_visitor.html

In Christ,
Steven Watanabe


Steven,

No I was aware of the visitors.  I am thinking more along the lines of

template< Signature>
void Execute( vector<variant> args, function<Signature> & Fun )
{
       fusion::vector< parameter_types<Signature>::type > typed_args(
magic_happens_here(args));
       fusion::invoke_procedure(Fun, typed_args);
}

What can I do to make the magic happen?

Regards,

Daniel Perry

Seems, to me you are looking for multi-methods, which might become the part of the next standard.

I can only find this document describing the approach, but there is no status on it:

http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2216.pdf


From this document you might also be able to derive you solution.


Ovanes