Advertisement

boost::asio序列使用了boost::bind和std::bind

阅读量:

1. 运用boost::bind技术进行函数绑定

复制代码
 #include <iostream>

    
 #include <boost/asio.hpp>
    
 #include <boost/bind.hpp>
    
 #include <boost/date_time/posix_time/posix_time.hpp>
    
  
    
 void print(const boost::system::error_code& /*e*/,
    
     boost::asio::deadline_timer* t, int* count)
    
 {
    
   if (*count < 5)
    
   {
    
     std::cout << *count << std::endl;
    
     ++(*count);
    
  
    
     t->expires_at(t->expires_at() + boost::posix_time::seconds(1));
    
     t->async_wait(boost::bind(print,
    
       boost::asio::placeholders::error, t, count));
    
   }

全部评论 (0)

还没有任何评论哟~