Boost logo

Boost :

From: John Maddock (john_at_[hidden])
Date: 2006-07-08 07:29:56

Peter Soetens wrote:
> Quoting Peter Dimov:
>> Peter Soetens wrote:
>>> Hi,
>>> I'm desperately seeking for doing this conversion using the boost
>>> libraries. User code often provides a function pointer, while
>>> library code often works with function types.
> [...]
>> One obvious way is
>> template<class F> boost::function<F> function_wrapper( F * pf )
>> {
>> return boost::function<F>( pf );
>> }
>> but a more interesting question is why do you need a
>> function_wrapper at all. Everything that you could do with the
>> returned function<F> (call it) is also possible with pf itself.
> Looking at the simplicity of that answer, this was clearly a
> boost-users question :-]. Sorry. This was a minimalistic example,
> removing the context.
> The big picture uses boost::function<F> to store partially bound
> objects, since this is a way to store the result of boost::bind for
> later use in a not templated class.
> I got confused by the boost::function_traits<T>, which only takes a
> "function type" and not a "function pointer type." I assumed one was
> not convertible to the other. I tried using boost::remove_pointer<F>,
> which didn't work and confirmed back then my assumption (confusingly,
> is_pointer<F> did work, but I could not remove it using
> type_traits...)

Are you sure about this?

::boost::is_function< ::boost::remove_pointer<int (*)(double)>::type>::value
yields true as expected for me.


Boost list run by bdawes at, gregod at, cpdaniel at, john at