Boost logo

Boost :

From: Peter Dimov (pdimov_at_[hidden])
Date: 2006-07-04 06:12:34


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. For example
> (function_conversion does the 'magic' here):
>
> int foo(int);
>
> template<class T,
> class R = typename function_conversion<T>::type >
> boost::function<R> function_wrapper(T t) {
> return boost::function<R>(t);
> }

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.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk