C++11 Template function that takes a std::function which depends of template parameters

前端 未结 3 947
北海茫月
北海茫月 2020-12-18 07:11

I am trying to write a template function that accepts a std::function which depends on the template arguments. Unfortunately the compiler is not capable of corr

3条回答
  •  佛祖请我去吃肉
    2020-12-18 07:32

    If you are using templates, you can avoid std::function entirely, unless for some reason you want to specifically restrict the function to take std::function:

    template < typename Ident, typename Param, typename Func >
    void CallFunc( Ident ident, Param param, Func op )
    {
        op( ident, param );
    }
    

提交回复
热议问题