我试图关注一个来自增强野兽的简单示例,我正在使用boost v1.58.0和来自v124库的野兽。
这是我的服务器启动代码:
void server::start () {
try {
auto const addr = boost::asio::ip::address::from_string(bind_addr);
boost::asio::io_service ioc{1};
boost::asio::ip::tcp::acceptor acc_{ioc, {addr, port}};
std::list<worker> webworkers;
for (int i=0;i<workers;i++) {
webworkers.emplace_back(acc_,doc_root);
webworkers.back().start();
}
if (spin) {
for(;;) ioc.poll();
} else {
ioc.run();
}
} catch (std::exception& e) {
std::cerr << "WebServer Failure: " << e.what() << std::endl;
}
}
当我尝试编译代码时,出现以下错误:
我正在关注这个例子:
https://github.com/boostorg/beast/tree/develop/example/http/server/fast
答案 0 :(得分:0)
此行正在尝试复制basic_acceptor
,而不是CopyConstructible类型:
webworkers.emplace_back(acc_,doc_root);
尝试移动新构造函数的接受器:
webworkers.emplace_back(boost::asio::ip::tcp::acceptor{ioc, {addr, port}},doc_root);