Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3494178
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T11:58:29+00:00 2026-05-18T11:58:29+00:00

The boost asio deadline_timer async_wait function is taking handler of the form : void

  • 0

The boost asio deadline_timer async_wait function is taking handler of the form :

void handler(const boost::system::error_code& error)

How could I define a handler which takes in const boost::system::error_code& error and also an argument of type int ?

boost::asio::deadline_timer t(io_service);

t.async_wait(handler); //I need the async_wait to take in handler which accepts argument boost::system::error_code& error and an int 

void handler(int, const boost::system::error_code& error )//extra int argument

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T11:58:29+00:00Added an answer on May 18, 2026 at 11:58 am

    You could use Boost.Bind to provide a value for the first argument :

    t.async_wait(boost::bind(handler, 0, _1));
    

    Here, the handler will be called with a 0 as its first argument and the error_code will simply be forwarded as a second argument.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm after a better example of the boost::asio::deadline_timer The examples given will always time
I'm using boost::asio, and I have code like this: void CServer::Start(int port) { tcp::acceptor
Just seen this inside <boost/asio.hpp> #ifndef BOOST_ASIO_HPP #define BOOST_ASIO_HPP #if defined(_MSC_VER) && (_MSC_VER >=
I've noticed that boost.asio has a lot of examples involving sockets, serial ports, and
i have little problem with boost::asio library. My app receive and process data asynchronously,
can you set SO_RCVTIMEO and SO_SNDTIMEO socket options in boost asio? If so how?
So I am doing a lot of high performance network programming using Boost::Asio (or
This simple example fails to compile in VS2K8: io_service io2; shared_ptr<asio::deadline_timer> dt(make_shared<asio::deadline_timer>(io2, posix_time::seconds(20))); As
I am trying to build a project using Boost's Asio and I am having
Boost.Asio documentation suggests the following exception handling pattern : boost::asio::io_service io_service; ... for (;;)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.