请注意,GLFWkeyfun
是函数 pointer 的类型。而是将函数类型指定为std::function
中std::function<void(GLFWwindow*,int,int)>
的模板参数。
我们应该将函数类型指定为std::function
。您可以在GLFWkeyfun
上应用std::remove_pointer
,例如
std::cout << std::is_same<std::function<std::remove_pointer_t<GLFWkeyfun>>,// ^^^^^^^^^^^^^^^^^^^^^^ ^
std::function<void(GLFWwindow*,int)>>::value
<< std::endl;
如果您的编译器不支持C ++ 14,那么
std::cout << std::is_same<std::function<std::remove_pointer<GLFWkeyfun>::type>,// ^^^^^^^^^^^^^^^^^^^^ ^^^^^^^
std::function<void(GLFWwindow*,int)>>::value
<< std::endl;
Demo
本文链接:https://www.f2er.com/3154581.html