Boost logo

Boost Users :

Subject: Re: [Boost-users] [phoenix] How to determine if a phoenix functor is callable?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-02-25 08:46:45


Joel de Guzman <joel <at> boost-consulting.com> writes:
> should be easy enough to detect. There is in fact something that you
> can use:
>
> template <typename T>
> struct is_actor;

Thanks, that will be useful. But I also need to determine if the phoenix
actor has an operator() that can be called with certain arguments. I will have
a functor passed to my library that may be binary vs. trinary and I go down
a different static code path depending on the case.

Perhaps the detection of is_callable here is near impossible without SFINAE
with expressions. But how about a simpler problem:

double binary_func(double x, double y){return x;}
double unary_func(double x){return x;}

auto unary_f = bind(&unary_func, _1);
auto binary_f = bind(&binary_func, _1, _2);
auto binary_f2 = _1 + _2;

static_assert(functor_arity<decltype(unary_f)>::value == 1, "");
static_assert(functor_arity<decltype(binary_f)>::value == 2, "");
static_assert(functor_arity<decltype(binary_f2)>::value == 2, "");

... is there a way to get a count of placeholders in an actor, etc?


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