C++11 variadic std::function parameter

前端 未结 4 1105
无人共我
无人共我 2020-12-14 02:41

A function named test takes std::function<> as its parameter.

template
void test(std::functio         


        
4条回答
  •  半阙折子戏
    2020-12-14 02:57

    It looks like you want to use overloading

    template
    void test(R f(A...))
    {
        test(std::function(f));
    }
    

    This simple implementation will accept most if not all the functions you will try to pass. Exotic functions will be rejected (like void(int...)). More work will give you more genericity.

提交回复
热议问题