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

后端 未结 4 1026
野性不改
野性不改 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条回答
  •  Happy的楠姐
    2021-02-04 01:37

    Is this what you want?

    #include 
    
    template
    T func(T x, T y)
    {
        return x+y;
    }
    
    template struct FunctionType
    {
        typedef std::function Type ;
    } ;
    
    int main()
    {
        FunctionType::Type Funcp = func ;
    }
    

提交回复
热议问题