I am using boost::asio::steady_timer _timer, but I found if using -std=c++11 flag, compiler will report error of can not convert type at:
boost::asio::steady_timer::time_point now() {
return boost::asio::steady_timer::clock_type::now();
}
and no match function for operator+() at:
_timer.expires_at(now()+boost::chrono::milliseconds(100));
It seems the compiler can not deduce the correct type in c++11 mode. But instead I using
boost::asio::basic_waitable_timer<boost::chrono::steady_clock> _timer;
and change boost::asio::steady_timer::time_point
to
boost::chrono::steady_clock::time_point
It is OK. However, they are same thing and work fine in g++ without 0x or 11 mode.
Is C++11 do something different thing about typedef deduce? Or a boost config problem?
The
basic_waitable_timerclass can work withstd::chronoorboost::chrono. On a recent g++, it usesstd::chronoby default. To force usingboost::chrono, defineBOOST_ASIO_DISABLE_STD_CHRONO.This is documented here