
On Mon, Jul 5, 2010 at 2:18 PM, joel falcou <joel.falcou@lri.fr> wrote:
Jeffrey Lee Hellrung, Jr. wrote:
You can, however, get away with querying whether a function object can be called with a specific signature, though the machinery to do this is relatively complex. I think something working is found in Boost.Proto as "can_be_called".
If the functor follow the result_of protocol, a traits can be made to test if a functor F can be called with arguments A0,..,An with a syntax like can_be_called<F(A0,...,An)>
Here is a sample implementation:
And if you know a signature of a functor, you can use function_types directly with the signature. For example, template<typename Signature> void f(const boost::function<Signature> &f) { using boost::function_types::parameter_types; using boost::function_types::function_arity; typedef typename parameter_types<Signature>::type params; // an mpl sequence const std::size_t arity = function_arity<Signature>::value; // ... } Daniel Walker