请问是否支持std::bind
在使用veigar::bind方法的时候是否支持使用std::bind作为参数
支持的
支持的
现在使用std::bind的时候报错no type named ‘args_kind 使用function包装下传入可以
Distributor ID: Ubuntu Description: Ubuntu 18.04.6 LTS gcc7.5.0
方便的话,把代码贴出来我看看吧
支持的
方便的话,把代码贴出来我看看吧
#include
using TEST = std::function<std::string(const std::string &msg, int i, double d, std::vector<uint8_t> buf)>;
std::string callback1(const std::string &msg, int i, double d, std::vector<uint8_t> buf) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); // 获取当前时间 字符串 time_t now = time(0); char *dt = ctime(&now); std::string time_str = dt; std::string result = "time:" + time_str; return result; }
int main() { Veigar vg; TEST t = std::bind(callback1, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4); //vg.bind("echo", std::bind(callback1,std::placeholders::_1, std::placeholders::_2, std::placeholders::_3, std::placeholders::_4)); vg.bind("echo", t);
vg.init("client-1");
std::this_thread::sleep_for(std::chrono::milliseconds(30000));
vg.uninit();
} 放开注释就会编译失败