asio service handler for stdin keypress
问题 I have adapted step 3 of the Boost asio tutorial to run forever, and display "tick" and "tock" once per second instead of the counter: #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) % 2) ) std::cout << "tick\n"; else std::cout << "tock\n"; ++(*count); t->expires_at(t->expires_at() + boost::posix_time: