$include_dir="/home/hyper-archives/boost-users/include"; include("$include_dir/msg-header.inc") ?>
From: Scott McMurray (me22.ca+boost_at_[hidden])
Date: 2008-08-09 14:27:30
On Fri, Aug 8, 2008 at 14:13, Jesse Perla <jlp400_at_[hidden]> wrote:
>
> Is there any way to get a normal function pointer out of a boost::function
> (with its state and potential bindings)? I want to have the option of
> calling existing optimization routines that are not functor aware. And
> hopefully including Fortran and C functions as well? I imagine that any
> solution to this would be hacky and potentially slow, but it would be nice
> to have the option without porting every optimization routine.
>
Boost.Thread needs to pass a plain function pointer to the native
libraries, but has a boost::function<void()>. You can probably use
the same trick it uses.
(Though IIRC, it only works if you can pass a void* data argument that
goes along with the function. If all you can pass is a, say,
double(*)(double), then you might be somewhat out of luck when it
comes to nice solutions. You can always use global variables to pass
the state, but those are obviously not nice.)