Boost logo

Boost Users :

From: Peter Soetens (peter.soetens_at_[hidden])
Date: 2006-07-04 07:32:05


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

My books write about function pointer types but do not mention
'function types'. These concepts appear to me underdocumented in
standard C++ works.

*Thanks a lot*.

Peter

-- 
www.fmtc.be
----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.

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