title: How to use lambda to for boost asio async completion handler
body: <pre><code>#include &lt;iostream&gt;
  #include &lt;boost/asio.hpp&gt;
  #include &lt;boost/bind.hpp&gt;
  #include &lt;boost/date_time/posix_time/posix_time.hpp&gt;
  
  void print(boost::asio::deadline_timer* t, int* count)
  {
      if (*count &lt; 5)
      {
          std::cout &lt;&lt; *count &lt;&lt; "\n";
          ++(*count);
  
          t-&gt;expires_at(t-&gt;expires_at() + boost::posix_time::seconds(1));
          t-&gt;async_wait(boost::bind(print, t, count));
      }
  }
  
  int main()
  {
      boost::asio::io_service io;
  
      int count = 0;
      boost::asio::deadline_timer t(io, boost::posix_time::seconds(1));
  //    t.async_wait(boost::bind(print, &amp;t, &amp;count));
      t.async_wait([&amp;]{ // compile error occurred
          print(&amp;t, &amp;count);
      });
  
      io.run();
  
      std::cout &lt;&lt; "Final count is " &lt;&lt; count &lt;&lt; "\n";
  
      return 0;
  }
  </code></pre>
  
  <blockquote>
    <p>What's the different between bind and lambda exp.? I guess it's OK in syntax, the problem is async_wait need a function object with param "const boost::system::error_code&amp; e".</p>
  </blockquote>