Spl*_*ash 3 c++ boost boost-asio c++11
我的目标是让我的项目使用没有Boost 的" asio "库,但使用C++ 11.示例是将此服务器代码转换为使用Timeout.
这是我做的:
boost::bind- > std::bind,_1- >std::placeholders::_1boost::asio::xxx- >asio::xxxboost::system::error_code - > asio::error_code现在,deadline_timer还有12个错误:
deadline_timer input_deadline_;
input_deadline_.expires_at(boost::posix_time::pos_infin);
...
void check_deadline(deadline_timer* deadline)
{
...
if (deadline->expires_at() <= deadline_timer::traits_type::now())
Run Code Online (Sandbox Code Playgroud)
什么是正确的代码使用?我正在使用GCC 4.9.1/2,并且新下载了asio库1.10.6.
您可以使用high_resolution_timer,它std::chrono在C++ 11编译器上使用:
#if defined(GENERATING_DOCUMENTATION)
/// Typedef for a timer based on the high resolution clock.
/**
* This typedef uses the C++11 @c <chrono> standard library facility, if
* available. Otherwise, it may use the Boost.Chrono library. To explicitly
* utilise Boost.Chrono, use the basic_waitable_timer template directly:
* @code
* typedef basic_waitable_timer<boost::chrono::high_resolution_clock> timer;
* @endcode
*/
typedef basic_waitable_timer<
chrono::high_resolution_clock>
high_resolution_timer;
#elif defined(ASIO_HAS_STD_CHRONO)
typedef basic_waitable_timer<
std::chrono::high_resolution_clock>
high_resolution_timer;
#elif defined(ASIO_HAS_BOOST_CHRONO)
typedef basic_waitable_timer<
boost::chrono::high_resolution_clock>
high_resolution_timer;
#endif
} // namespace asio
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1083 次 |
| 最近记录: |