Boost logo

Boost :

Subject: Re: [boost] [function_types] is there an equivalent for functors?
From: Edd Dawson (lists_at_[hidden])
Date: 2010-07-05 16:34:59


On 7/5/2010 8:53 PM, Daniel Walker wrote:
>
> Also, another thought, if the call operators on your function objects
> are not overloaded, you can do something like the following without
> having to know the signature.
>
> template<typename Functor, typename CallOperator>
> void f(const Functor&f, CallOperator)
> {
> using boost::function_types::parameter_types;
> using boost::function_types::function_arity;
>
> typedef typename parameter_types<CallOperator>::type params; // an
> mpl sequence
> const std::size_t arity = function_arity<CallOperator>::value;
> // ...
> }
>
> struct F {
> void operator()(int) {}
> };
>
> int main()
> {
> f(F(),&F::operator());
> }

That's a nice trick, thanks! I might be able to use that for the general case.
Unfortunately a bind expression seems to have tens of overloads :(

Kind regards,

Edd


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk