c++ – Boost no matching member function for call to ‘async_wait’
I am learning boost and trying to run example code: www.boost.org/doc/libs/master/doc/html/boost_asio/tutorial/tuttimer3/src.html
Boost version is 1.83.0
I have an error:
main.cpp:14:8: error: no matching member function for call to 'async_wait'
t->async_wait(std::bind(print,
~~~^~~~~~~~~~
My code
#include
#include
#include
void print(const boost::system::error_code& /*e*/,
boost::asio::steady_timer* t, int* count)
{
if (*count < 5)
{
std::cout << *count << std::endl;
++(*count);
t->expires_at(t->expiry() + boost::asio::chrono::seconds(1));
t->async_wait(std::bind(print,
boost::asio::placeholders::error, t, count));
}
}
int main()
{
boost::asio::io_context io;
int count = 0;
boost::asio::steady_timer t(io, boost::asio::chrono::seconds(1));
t.async_wait(std::bind(print,
boost::asio::placeholders::error, &t, &count));
io.run();
std::cout << "Final count is " << count << std::endl;
return 0;
}
Read more here: Source link
