|
Boost Users : |
Subject: Re: [Boost-users] [phoenix] How to determine if a phoenix functor is callable?
From: Joel de Guzman (joel_at_[hidden])
Date: 2010-02-24 20:53:06
On 2/24/2010 10:36 PM, Jesse Perla wrote:
> So there any ways to implement a metafunction can_be_called on a phoenix
> functor s.t.:
> auto f = _1 + _2;
> static_assert(is_callable<decltype(f), double, double>::value, "");
> static_assert(!is_callable<decltype(f), double, NonArithmeticType>::value, "");
> static_assert(!is_callable<decltype(f), double>::value, ""); //Needs 2 args
>
>
> A while back, I was pointed towards the following from proto to determine
> if a functor was callable:
> http://www.boost.org/doc/libs/1_42_0/doc/html/proto/appendices.html#boost_proto.ap
> pendices.implementation.function_arity
>
> This seemed to work well for most of my custom built functors, but as far as I
> can tell, the trick doesn't work for either boost::lambda or boost::phoenix
> functors (or std::tr1::bind for that matter). I can post a test case
> for phoenix if people think that it should work.
All phoenix callables are 'actors':
template <typename Eval>
struct actor;
should be easy enough to detect. There is in fact something that you
can use:
template <typename T>
struct is_actor;
Regards,
-- Joel de Guzman http://www.boostpro.com http://spirit.sf.net http://www.facebook.com/djowel Meet me at BoostCon http://www.boostcon.com/home http://www.facebook.com/boostcon
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