If there is one, and then further, have not a layer of overall quality function solution package?
CodePudding user response:
Here are the answersA lambda can only be converted to A function pointer if it does not capture, the from the draft standard c + + 11 section 5.1.2 [expr. Prim. Lambda] says (emphasis mine) :
The closure type for a lambda expression - with no lambda - The capture from a public non - virtual non - explicit const conversion function to pointer to The function having The same parameter and return types as The closure type 's function call operator. The value returned by this conversion function shall be The address of a function that, when invoked, has The same effect as invoking The closure type' s function call operator.
https://www.apiref.com/cpp-zh/cpp/utility/functional/function/target.html
CodePudding user response:
Do you want to get a private function pointer?CodePudding user response:
Talk is being. Show me the code.CodePudding user response:
Own handwriting class:
Bool Windows: : Init ()
{
.
FunctionIf (fun. Target Cout & lt; <"Fun null \ n";
GlfwSetFramebufferSizeCallback (window, fun. Target
//glfwSetCursorPosCallback (window, MouseCallback);
//glfwSetScrollCallback (window, ScrollCallback);
.
}
Void Windows: : FrameBufferSizeCallBack (GLFWwindow * Window, int width, int height)
{
GlViewport (0, 0, width, height);
}
Call API interface:
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback (GLFWwindow * window, GLFWframebuffersizefun callback);
GLFWframebuffersizefun is a function pointer form:
Typedef void (* GLFWwindowmaximizefun) (GLFWwindow *, int);
CodePudding user response: