Boost logo

Boost Users :

From: John Maddock (john_at_[hidden])
Date: 2007-10-01 12:23:31


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 > >

But you may want to wrap that up in a small traits class to avoid repeated
typing :-)

HTH John.

PS My simple test case is this:

#include <boost/type_traits/function_traits.hpp>
#include <boost/type_traits/remove_pointer.hpp>

int foo()
{
  return 0;
}

template <class F>
typename boost::function_traits<typename
boost::remove_pointer<F>::type>::result_type
test_call(F f)
{
  return f();
}

int main()
{
  test_call(foo);
}


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