0

I'm trying to make this code compile:

typedef void (*func_ptr)();

boost::function<void()> bf;
func_ptr fp = [bf] { bf(); };

Visual Studio 2015 complains that no suitable conversion from lambda []void()->void to void (*const)() exists.

What am I missing?

François Beaune
  • 4,270
  • 7
  • 41
  • 65
  • 2
    You cannot convert a capturing lambda into a regular function pointer... there's data involved. – StoryTeller - Unslander Monica Jun 11 '17 at 09:39
  • Ah, good point. I need to backtrack a bit then: What I'm trying to do is have a `boost::lockfree::queue<>` of functions but since `boost::function` is neither trivially assignable nor destructable, I'm trying with a `boost::lockfree::queue`, in the spirit of this: https://stackoverflow.com/questions/21405837/can-i-have-a-boost-lock-free-queue-of-lambdas. – François Beaune Jun 11 '17 at 09:59

0 Answers0