std::function -> function pointer

后端 未结 2 1550
暗喜
暗喜 2020-12-19 00:54

Here is a code:

#include 
using namespace std::tr1;

typedef void(*fp)(void);

void foo(void)
{

}

void f(fp)
{

}

int main()
{
  functio         


        
2条回答
  •  孤城傲影
    2020-12-19 01:17

    You can't convert a std::function to a function pointer(you can do the opposite). You should use either function pointers, or std::functions. If you can use std::function instead of pointers, then you should.

    This makes your code work:

    typedef function fp;
    

提交回复
热议问题