
John Maddock wrote:
Kirit Sælensminde wrote:
That makes perfect sense, unfortunately it doesn't help.
From the worker thread example I've removed the specialisation for R(**)(void) - I can't work out why there is a double indirection there, but it might well be contributing to the problem.
I've also changed the functor that does the type handling to this:
template< typename F > boost::shared_ptr< Future< typename boost::function_traits< F
::result_type > > operator()( F f ) { return run< typename boost::function_traits< typename boost::remove_pointer< F >::type >::result_type >( f ); }
The return type should probably be:
boost::shared_ptr< Future< typename boost::function_traits< typename boost::remove_pointer<F>::type>::result_type > >
You're right. What a muppet I am :( I think I have a misunderstanding of what the boost::function_traits is doing. From your explanation it seems that boost::function_traits is there to examine only function signatures where a function type is of the form R( A1, A2, etc. ), whereas I'm thinking of it as something to examine any unambiguous callable item. I.e. function pointers, member functions, all kinds of lambdas etc. What I've found is that if I add the specialisations to boost::details::function_traits_helper I *can* use it how I expect. Is the reason for leaving them out? Something technical that I'm missing so I'm just storing up trouble for myself in the long run? What is the proper way of doing this? Given a choice between having to write lots of overloaded functions to deal with the different possibilities every time I want to write a function that needs to do some type deduction and adding specialisations just once I know which feels most appealing. For example, if I've understood the mem_fn documentation properly (and I'm by no means sure that I have) it seems I have to either say that users of safe_call need to wrap the member up like this: safe_call( ptr, boost::mem_fn( &foo::bar ) )( a1, a2 ); Or I have to overload safe_call for every parameter combination that there might be: template< typename C, typename R > safe_call( C *ptr, R (C::*)() ); template< typename C, typename R, typename A1 > safe_call( C *ptr, R (C::*)( A1 ) ); It seems simpler to handle this by extending boost::function_traits to deal with member functions - which is what I've done. I'm thinking I'm missing some other way of doing this. K