I\'ve got a library that I need to use that defines the following:
typedef void CallbackFunction(const int& i);
and has a function to regis
In general, no you can't use a lambda or function object where a function pointer is required. Function objects are full-fledged objects that have overloaded the application operator (()
) so you can use them as functions syntactically.
The standard algorithms are written as templates, which allows you to pass either a function address (pointer) or a function object to them, because they use the same syntax. When you pass a function object, a template is instantiated which accepts that function object; when you pass a function pointer, a different template is instantiated.
So to get lambdas/function objects to work with your code, you would need to modify the library you're using.