how to use std::function to point to a function template

后端 未结 4 996
野性不改
野性不改 2021-02-04 01:29
#include 

int func(int x, int y)
{
    return x+y;
}

int main()
{
    typedef std::function Funcp;
    Funcp funcp = func;

             


        
4条回答
  •  醉酒成梦
    2021-02-04 01:37

    As Erik points out, this is not possible directly. To achieve the effect you probably desire, you would have to make the code that uses the pointer a template.

提交回复
热议问题