Boost logo

Boost Users :

Subject: [Boost-users] [phoenix] How to determine if a phoenix functor is callable?
From: Jesse Perla (jesseperla_at_[hidden])
Date: 2010-02-24 09:36:34


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.

-Jesse


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