jeudi 25 juillet 2019

Passing lambda to asio async_wait

Why passing a lambda to asio asyn_wait() needs auto ... parameter, whereas passing a function doesn't require such a thing (ie just function name would be ok) as in timer.async_wait( &print );

int main()
{
    boost::asio::io_service io_service;

    boost::asio::deadline_timer timer( io_service, boost::posix_time::seconds(5) );
    timer.async_wait( []( auto ... ){   //# ?
        std::cout << timestamp() << ": timer expired\n";
    });

    std::cout << timestamp() << ": calling io_service run\n";

    io_service.run();

    std::cout << timestamp() << ": done\n";

    return 0;
}

Aucun commentaire:

Enregistrer un commentaire