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

前端 未结 3 943
北海茫月
北海茫月 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:45

    You can do the conversion inline or use bind. Neither is particularly pretty, but they get the job done:

    CallFunc(id, param, std::function(DoSomething));
    

    CallFunc(id, param, std::bind(DoSomething, std::placeholders::_1, std::placeholders::_2));
    

提交回复
热议问题