function_traits and functors

Is it possible to use function_traits to decompose functors? Specifically is this supposed to work? void test_helper( int a ) { } template< class Handler > void test( Handler h ) { typedef typename boost::function_traits<Handler>::arg1_type ArgType; } int main() { test( boost::bind(&test_helper,_1) ); } Thanks, -- Michael Marcin

Steven Watanabe wrote:
AMDG
Michael Marcin wrote:
Is it possible to use function_traits to decompose functors?
No. Functors can be overloaded or templated.
I see that makes sense but I still really want to do it. :) Maybe if I provide overloads based on is_bind_expression sfinae to know if it is a bind I can find the type of the first argument of bind somehow? Then I can add overloads for real functions and boost::function to do the same. I basically want to be able to pass any function or functor in and make sure its first parameter is a boost::shared_ptr<T> where T could be any type and then additionally find out what type T is. I have a hard time reading the documentation but the proposed Boost Channel library* seems to require callbacks to take a shared_ptr<void> as the message data. I don't want the users to have to downcast this themselves. Instead I want to wrap the message handlers in a function object that will downcast the shared_ptr<void> to the appropriate type and then call the user handler. * http://channel.sourceforge.net/ Thanks, -- Michael Marcin
participants (2)
-
Michael Marcin
-
Steven Watanabe