[asio][chrono] using steady_timer portably

Hello, There's some use of asio::steady_timer in my code (1.51): asio::steady_timer timer_; //....... timer_.expires_from_now(boost::chrono::milliseconds(100)); //...... However, the above appears to be non-portable, as under c++11 steady_timer uses std::chrono, while boost::chrono doesn't seem to "forward" its types to std::chrono. I know I can use asio::basic_waitable_timerboost::chrono::steady_clock explicitly, but maybe there's some more straightforward solution (eg. boost::chrono configuration)? Thanks.

Le 15/01/13 12:33, Igor R a écrit :
Hello,
There's some use of asio::steady_timer in my code (1.51):
asio::steady_timer timer_; //....... timer_.expires_from_now(boost::chrono::milliseconds(100)); //......
However, the above appears to be non-portable, as under c++11 steady_timer uses std::chrono, while boost::chrono doesn't seem to "forward" its types to std::chrono. I know I can use asio::basic_waitable_timerboost::chrono::steady_clock explicitly,
Agreed. I think there is a problem on the ASIO interface for steady_timer as it changes depending on the context.
but maybe there's some more straightforward solution (eg. boost::chrono configuration)?
I don't understand what do you mean. Could you elaborate? Best, Vicente

Agreed. I think there is a problem on the ASIO interface for steady_timer as it changes depending on the context.
but maybe there's some more straightforward solution (eg. boost::chrono configuration)?
I don't understand what do you mean. Could you elaborate?
Well, actually I've already found such a configuration in ASIO: BOOST_ASIO_DISABLE_STD_CHRONO.
participants (2)
-
Igor R
-
Vicente J. Botet Escriba