Search code examples
c++dllboostbind

Sending parameters to a DLL to be boost::bind'ed


I have a DLL which has a function which accepts a function pointer converts it to a boost::function. This is then stored and then called from inside the DLL.

I want to add a function to the DLL to handle member functions in a similar way. I know I need to use boost::bind to wrap the member function pointer and the object together. I want to do the binding on the DLL side though so the EXE does not require boost libraries to be included.

How would you write this function? One which accepts a member function pointer and an object as arguments and binds them together.

Thanks!


Solution

  • you're warned by @Kylotan, so you can try something like this:

    __declspec(dllexport) void store_mem_fn(void(Your_class::*mem_fn)(void), Your_class& instance)
    {
        std::vector<boost::function<void(void)> > container;
        container.push_back(boost::bind(mem_fn, instance));
    }