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 8873387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:27:08+00:00 2026-06-14T18:27:08+00:00

I’m having a bit of a problem understanding the compile errors I’m getting when

  • 0

I’m having a bit of a problem understanding the compile errors I’m getting when trying to create a boost::asio::deadline_timer. I get the errors below with the following code example on MSVC10. It was built with Boost 1.48

The first error looks like it is complaining about a member function set as a handler to async_wait being a reference. However, when I change the argument it gives a similar error.

I’ve been looking at Boost::Bind and Boost::Asio to try and figure out what I’m doing wrong. My code is similar to this example with the way I use bind and deadline_timer.

Sorry about how messy the compile errors look. I’m still trying to get a handle on Markdown.

Code Example

include

#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/asio.hpp>
#include <boost/system/error_code.hpp>
#include <boost/date_time/posix_time/posix_time.hpp>

class TimerThing
{
protected:
    boost::asio::deadline_timer* statusTimer_;
    boost::thread_group worker_threads_;

    boost::asio::io_service io_service_;
    boost::shared_ptr<boost::asio::io_service::work> work_;

public:
    TimerThing() {}

    virtual ~TimerThing(){}

    void updateStatus(boost::system::error_code& ec)
    {
        if (ec == boost::asio::error::operation_aborted)
            return;

        std::cout<<"Status Update"<<std::endl;

        statusTimer_->expires_at(statusTimer_->expires_at() + boost::posix_time::seconds(1));
        statusTimer_->async_wait(boost::bind(&TimerThing::updateStatus, this, , boost::asio::placeholders::error));
    }

    void start()
    {
        statusTimer_=new boost::asio::deadline_timer(io_service_);
        boost::shared_ptr<boost::asio::io_service::work> myWork(new boost::asio::io_service::work(io_service_));
        work_=myWork;

        worker_threads_.create_thread( boost::bind( &TimerThing::threadAction, this ) );

        statusTimer_->expires_at(statusTimer_->expires_at() + boost::posix_time::seconds(1));
        statusTimer_->async_wait(boost::bind(&TimerThing::updateStatus, this, boost::asio::placeholders::error));
    }

    void threadAction()
    {
        io_service_.run();
    }

    void stop()
    {
        work_.reset();
        io_service_.stop();
        worker_threads_.join_all();

        delete statusTimer_;
    }

};



#include "TimerThing.h"

int main(int argc, const char* argv[] )
{
    TimerThing t;

    std::string input;
    std::cout<<"Press f to stop"<<std::endl;

    t.start();

    std::cin>>input;

    t.stop();

    return 0;
}

Compiler errors

c:\Underware\version\include\boost/bind/bind.hpp(313): error C2664: ‘R boost::_mfi::mf1::operator ()(const U &,A1) const’ : cannot convert parameter 2 from ‘const boost::system::error_code’ to ‘boost::system::error_code &’

     with
     [
         R=void,
         T=TimerThing,
         A1=boost::system::error_code &,
         U=TimerThing *
     ]
     Conversion loses qualifiers
     c:\Underware\version\include\boost/bind/bind_template.hpp(47) : see reference to function template instantiation 'void boost::_bi::list2<A1,A2>::operator ()<F,boost::_bi::list1<const boost::system::error_code &>>(boost::_bi::type<T>,F &,A &,int)' being compiled
     with
     [
         A1=boost::_bi::value<TimerThing *>,
         A2=boost::arg<1>,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         T=void,
         A=boost::_bi::list1<const boost::system::error_code &>
     ]
     c:\Underware\version\include\boost/asio/detail/bind_handler.hpp(46) : see reference to function template instantiation 'void boost::_bi::bind_t<R,F,L>::operator ()<const Arg1>(const A1 &)' being compiled
     with
     [
         R=void,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         L=boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>,
         Arg1=const boost::system::error_code,
         A1=const boost::system::error_code
     ]

     c:\Underware\version\include\boost/asio/detail/bind_handler.hpp(45) : while compiling class template member function 'void boost::asio::detail::binder1<Handler,Arg1>::operator ()(void)'
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Arg1=boost::system::error_code
     ]
     c:\Underware\version\include\boost/asio/detail/wait_handler.hpp(59) : see reference to class template instantiation 'boost::asio::detail::binder1<Handler,Arg1>' being compiled
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Arg1=boost::system::error_code
     ]

     c:\Underware\version\include\boost/asio/detail/wait_handler.hpp(45) : while compiling class template member function 'void boost::asio::detail::wait_handler<Handler>::do_complete(boost::asio::detail::io_service_impl *,boost::asio::detail::operation *,const boost::system::error_code &,size_t)'
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/detail/deadline_timer_service.hpp(185) : see reference to class template instantiation 'boost::asio::detail::wait_handler<Handler>' being compiled
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/deadline_timer_service.hpp(137) : see reference to function template instantiation 'void boost::asio::detail::deadline_timer_service<Time_Traits>::async_wait<WaitHandler>(boost::asio::detail::deadline_timer_service<Time_Traits>::implementation_type &,Handler)' being compiled
     with
     [
         Time_Traits=boost::asio::time_traits<boost::posix_time::ptime>,
         WaitHandler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/basic_deadline_timer.hpp(502) : see reference to function template instantiation 'void boost::asio::deadline_timer_service<TimeType,TimeTraits>::async_wait<WaitHandler>(boost::asio::detail::deadline_timer_service<Time_Traits>::implementation_type &,const WaitHandler &)' being compiled
     with
     [
         TimeType=boost::posix_time::ptime,
         TimeTraits=boost::asio::time_traits<boost::posix_time::ptime>,
         WaitHandler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Time_Traits=boost::asio::time_traits<boost::posix_time::ptime>
     ]

c:\users\tharper\documents\visual studio 2010\projects\asiotimer\asiotimer\TimerThing.h(48) : see reference to function template instantiation ‘void boost::asio::basic_deadline_timer::async_wait>(const WaitHandler &)’ being compiled

     with
     [
         Time=boost::posix_time::ptime,
         R=void,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         L=boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>,

WaitHandler=boost::_bi::bind_t,boost::_bi::list2,boost::arg<1>>>
]
TimerThing.cpp

c:\Underware\version\include\boost/bind/bind.hpp(313): error C2664: ‘R boost::_mfi::mf1::operator ()(const U &,A1) const’ : cannot convert parameter 2 from ‘const boost::system::error_code’ to ‘boost::system::error_code &’

     with
     [
         R=void,
         T=TimerThing,
         A1=boost::system::error_code &,
         U=TimerThing *
     ]
     Conversion loses qualifiers

c:\Underware\version\include\boost/bind/bind_template.hpp(47) : see reference to function template instantiation ‘void boost::_bi::list2::operator ()>(boost::_bi::type,F &,A &,int)’ being compiled

     with
     [
         A1=boost::_bi::value<TimerThing *>,
         A2=boost::arg<1>,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         T=void,
         A=boost::_bi::list1<const boost::system::error_code &>
     ]
     c:\Underware\version\include\boost/asio/detail/bind_handler.hpp(46) : see reference to function template instantiation 'void boost::_bi::bind_t<R,F,L>::operator ()<const Arg1>(const A1 &)' being compiled
     with
     [
         R=void,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         L=boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<>>,
         Arg1=const boost::system::error_code,
         A1=const boost::system::error_code
     ]
     c:\Underware\version\include\boost/asio/detail/bind_handler.hpp(45) : while compiling class template member function 'void boost::asio::detail::binder1<Handler,Arg1>::operator ()(void)'
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Arg1=boost::system::error_code
     ]
     c:\Underware\version\include\boost/asio/detail/wait_handler.hpp(59) : see reference to class template instantiation 'boost::asio::detail::binder1<Handler,Arg1>' being compiled
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Arg1=boost::system::error_code
     ]
     c:\Underware\version\include\boost/asio/detail/wait_handler.hpp(45) : while compiling class template member function 'void boost::asio::detail::wait_handler<Handler>::do_complete(boost::asio::detail::io_service_impl *,boost::asio::detail::operation *,const boost::system::error_code &,size_t)'
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/detail/deadline_timer_service.hpp(185) : see reference to class template instantiation 'boost::asio::detail::wait_handler<Handler>' being compiled
     with
     [
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/deadline_timer_service.hpp(137) : see reference to function template instantiation 'void boost::asio::detail::deadline_timer_service<Time_Traits>::async_wait<WaitHandler>(boost::asio::detail::deadline_timer_service<Time_Traits>::implementation_type &,Handler)' being compiled
     with
     [
         Time_Traits=boost::asio::time_traits<boost::posix_time::ptime>,
         WaitHandler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Handler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
     c:\Underware\version\include\boost/asio/basic_deadline_timer.hpp(502) : see reference to function template instantiation 'void boost::asio::deadline_timer_service<TimeType,TimeTraits>::async_wait<WaitHandler>(boost::asio::detail::deadline_timer_service<Time_Traits>::implementation_type &,const WaitHandler &)' being compiled
     with
     [
         TimeType=boost::posix_time::ptime,
         TimeTraits=boost::asio::time_traits<boost::posix_time::ptime>,
         WaitHandler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>,
         Time_Traits=boost::asio::time_traits<boost::posix_time::ptime>
     ]
     c:\users\tharper\documents\visual studio 2010\projects\asiotimer\asiotimer\TimerThing.h(48) : see reference to function template instantiation 'void boost::asio::basic_deadline_timer<Time>::async_wait<boost::_bi::bind_t<R,F,L>>(const WaitHandler &)' being compiled
     with
     [
         Time=boost::posix_time::ptime,
         R=void,
         F=boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,
         L=boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>,
         WaitHandler=boost::_bi::bind_t<void,boost::_mfi::mf1<void,TimerThing,boost::system::error_code &>,boost::_bi::list2<boost::_bi::value<TimerThing *>,boost::arg<1>>>
     ]
  • 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-06-14T18:27:09+00:00Added an answer on June 14, 2026 at 6:27 pm

    void updateStatus(boost::system::error_code& ec) should be void updateStatus(const boost::system::error_code& ec).

    And you have extra comma in boost::bind(&TimerThing::updateStatus, this, , boost::asio::placeholders::error));

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

Sidebar

Related Questions

I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to create an if statement in PHP that prevents a single post
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
I am currently running into a problem where an element is coming back from
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I've tracked down a weird MySQL problem to the two different ways I was

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.