我在那里工作的事情使用提升的地方::线程差异::线程
std::vector<boost::shared_ptr<boost::thread> > threads;
for (std::size_t i = 0; i < io_services_.size(); ++i)
{
boost::shared_ptr<boost::thread> thread(new boost::thread(
boost::bind(&boost::asio::io_service::run, io_services_[i])));
threads.push_back(thread);
}
如果我尝试用STD使用(使用boost :: ASIO为例):线程我得到编译错误:
std::vector<std::thread> threads;
for (std::size_t i = 0; i < this->ioServices.size(); ++i)
{
std::thread thread(&boost::asio::io_service::run, ioServices[i]); // compile error std::thread::thread : no overloaded function takes 2 arguments
threads.push_back(std::move(thread));
}
相关:http://stackoverflow.com/questions/10555566/is-there-any-difference-between-c11-stdbind-and-boostbind –
你的编译错误不包含对'boost :: bind'的调用? – Chad
@BartekBanachewicz更新了标题,因为这是关于boost :: tread和std :: thread之间的区别 – Gmt