Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

5
  • 6
    Do you need the versatility of std::function? Could you change the first parameter of Integerate to be a function pointer? Because there's no way you're going to be able to use a std::function as a function pointer, unless you get into some very ugly global variable business. Note that you can store a lambda in a function pointer, as long as it doesn't capture, which, in the example you showed, it does not. Commented Nov 8, 2012 at 12:48
  • There's your answer, in the final sentence of the first comment. Commented Nov 8, 2012 at 12:59
  • Actually no need for globals, since the C interface includes a void* parameter to be passed through. Commented Nov 8, 2012 at 13:01
  • At first I actualy didn't need it, but seeing sellibitze's (and ecatmur's) answers, I found that using std::function I can drop the void * stuff now. Commented Nov 8, 2012 at 13:33
  • Answer came quite late, but that wrap can help you a lot with this kind of problems. It can also be used to integrate member functions, to bind extra parameters.... Commented Aug 31, 2013 at 0:44