I have the following code that can convert a lambda into a C-style function pointer. This works for all lambdas including lambdas with captures.