Boost logo

Boost Users :

From: Kirit Sælensminde (kirit.saelensminde_at_[hidden])
Date: 2007-10-01 11:38:48


John Maddock wrote:
> Kirit Sælensminde wrote:
>> I'm wondering if finding the need to add specialisations of
>> boost::detail::function_traits_helper is a result of missing headers,
>> incorrect usage or just things that have not been added to
>> Boost.TypeTraits on purpose?
>
> Not added on purpose: function_traits works for *function types*, and not
> *pointer to function types*.
>
> So:
>
> functions_traits<int(double)> OK.
> function_traits<int(*)(double)> bad: argument not a function type.
>
> You can always use remove_pointer to strip a function-pointer down to a
> function type.
>
> HTH, John.

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 );
}

And even 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< typename boost::remove_pointer< F >::type >::type
>::result_type >( f );
}

I get exactly the same error in either case:

1>e:\dev\trunk\clients\kirit saelensminde\samples\boost cookbook\worker
thread\worker thread.cpp(112) : warning C4355: 'this' : used in base
member initializer list
1>e:\dev\boost\install\basic\include\boost-1_34\boost\type_traits\function_traits.hpp(170)
: error C2504: 'boost::detail::function_traits_helper<Function>' : base
class undefined
1> with
1> [
1> Function=int (__cdecl **)(void)
1> ]
1> e:\dev\trunk\clients\kirit saelensminde\samples\boost
cookbook\worker thread\worker thread.cpp(209) : see reference to class
template instantiation 'boost::function_traits<Function>' being compiled
1> with
1> [
1> Function=int (__cdecl *)(void)
1> ]
1>e:\dev\trunk\clients\kirit saelensminde\samples\boost cookbook\worker
thread\worker thread.cpp(209) : error C2893: Failed to specialize
function template
'boost::shared_ptr<Worker::Future<boost::function_traits<Function>::result_type>>
Worker::operator ()(F)'
1> With the following template arguments:
1> 'int (__cdecl *)(void)'

Is this a dependant type problem stopping the remove_pointer from working?

K


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