
4 Jul
2006
4 Jul
'06
10:12 a.m.
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.