Are there any differences?
What is the best way to save / migrate?
function<void(int)> fcn = [](int par) {std::cout<<"fcn: "<<par<<std::endl; }; void(*fcn_a)(int) = [](int par) {std::cout<<"fcn_a: "<<par<<std::endl; }; fcn(12); fcn_a(12);
std::functionmore general - you can save any called object with the correct signature in it (function pointer, method pointer, object c operator()), and you can build std::functionusing std :: bind .
std::function
operator()
A function pointer can only accept functions with the correct signature, but it can be a little faster and can generate slightly smaller code.
- , std::function. , std::function . , , operator(), .
OTOH, lambdas . , std::function , .
Source: https://habr.com/ru/post/1570830/More articles:How to create local variables inside the main function? - assemblyHow to set default cursor position to the right of EditText - androidPandas DataFrame, replace the column value with the value of another column - pythonHow to use didMoveToView as initWithSize? - objective-cMaven compilation for GWT 2.7 SOYC crashes - gwt-2.7understanding the following javascript code - javascriptjava / jersey / jackson - JSON input confirmation - javaSwift enum - limit bound values - enumshow to increase MaxReceivedMessageSize when calling WCF with vb.net - c #WCF maxReceivedMessagesize and readerquotas - wcfAll Articles