[英]C++11 type deduce with asio
我正在使用boost::asio::steady_timer _timer
,但是我發現如果使用-std = c ++ 11標志,編譯器將在以下位置報告無法轉換類型的錯誤:
boost::asio::steady_timer::time_point now() {
return boost::asio::steady_timer::clock_type::now();
}
並且在以下位置沒有用於operator +()的匹配函數:
_timer.expires_at(now()+boost::chrono::milliseconds(100));
看來編譯器無法在c ++ 11模式下推斷出正確的類型。 但是我使用
boost::asio::basic_waitable_timer<boost::chrono::steady_clock> _timer;
並將boost::asio::steady_timer::time_point
為boost::chrono::steady_clock::time_point
沒關系。 但是,它們是相同的,並且在沒有0x或11模式的g ++中可以正常工作。
C ++ 11是否對typedef演繹有所不同? 還是Boost配置問題?
basic_waitable_timer
類可以與std::chrono
basic_waitable_timer
或boost::chrono
basic_waitable_timer
一起使用。 在最近的g ++中,默認情況下使用std::chrono
。 要強制使用boost::chrono
BOOST_ASIO_DISABLE_STD_CHRONO
,請定義BOOST_ASIO_DISABLE_STD_CHRONO
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.