Boost logo

Boost Users :

Subject: Re: [Boost-users] [fusion?] [Phoenix?] Calling arbitrary method with collection of args
From: Nat Goodspeed (nat_at_[hidden])
Date: 2010-03-19 09:38:20


Kim Kuen Tang wrote:

> You can use push_back from phoenix to fill in your data type. See
> http://www.boost.org/doc/libs/1_42_0/libs/spirit/phoenix/doc/html/phoenix/container.html
>
>
> Perhaps you can show us your data type so we can go into detail.

I'm talking about the LLSD class:
http://svn.secondlife.com/trac/linden/browser/trunk/indra/llcommon/llsd.h

I'm confused by your answer, though, so I probably asked the question badly.

I'm looking for something equivalent to this pseudocode:

template <typename CALLABLE>
typename boost::function_traits<CALLABLE>::result_type
apply(const CALLABLE& callable, const LLSD& args)
{
     // 'args' is already filled
     // for present purposes, assume we know it contains an array
     // call 'callable', supplying its args from that array
     if (boost::function_traits<CALLABLE>::arity == 0)
     {
         return callable();
     }
     if (boost::function_traits<CALLABLE>::arity == 1)
     {
         return callable(args[0]);
     }
     if (boost::function_traits<CALLABLE>::arity == 2)
     {
         return callable(args[0], args[1]);
     }
     // ...etc. to some max arity...
}

I could possibly write such code, using partial template specialization
on boost::function_traits<CALLABLE>::arity instead of a sequence of 'if'
statements.

My point is that I assume Boost already contains something like this.
I'm just not sure where to look. Thanks for any pointers to the
appropriate documentation.


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