wildcard function pointer non-type template parameter

前端 未结 2 1983
清酒与你
清酒与你 2021-01-28 11:34

Templates can take non-type function pointer parameters, but there is a problem if all possible function pointer parameters are accepted, example:

void dummy()
{         


        
2条回答
  •  轻奢々
    轻奢々 (楼主)
    2021-01-28 12:11

    If you know the signature of the function you wish to call (and surely you do), can't you do

    template
    void proxy()
    {
        F();
    }
    
    void dummy() {}
    
    int main()
    {
        proxy();
    }
    

提交回复
热议问题