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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T17:28:08+00:00 2026-05-30T17:28:08+00:00

I am trying to adapt one of the boost::asio examples to use c++11 /

  • 0

I am trying to adapt one of the boost::asio examples to use c++11 / TR1 libraries where possible. The original code looks like this:

void start_accept()
{ 
  tcp_connection::pointer new_connection =
    tcp_connection::create(acceptor_.get_io_service());

  acceptor_.async_accept(new_connection->socket(),
      boost::bind(&tcp_server::handle_accept, this, new_connection,
         boost::asio::placeholders::error));
}

If I replace boost::bind with std::bind as follows:

void start_accept()
{ 
  tcp_connection::pointer new_connection =
    tcp_connection::create(acceptor_.get_io_service());

  acceptor_.async_accept(new_connection->socket(),
      std::bind(&tcp_server::handle_accept, this, new_connection,
                 boost::asio::placeholders::error ) );
      // std::bind(&tcp_server::handle_accept, this, new_connection, _1 ) );
}

I get a large error message, with ends with:

/usr/include/c++/4.4/tr1_impl/functional:1137: error: return-statement with a value, in function returning 'void'

I am using gcc version 4.4 with boost version 1.47

I expected boost::bind and std::bind to be interchangeable.

  • 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-30T17:28:09+00:00Added an answer on May 30, 2026 at 5:28 pm

    I now have a solution

    The problem is that when I first tried to switch to std::bind and std::shared_ptr I was still using the boost::asio::placeholders with std::bind, this resulted in a large amount of template compiler errors, so I then tried to switch piecemeal.

    I first tried switching just boost::shared_ptr to std::shared_ptr, this failed because boost::bind will not work with std::shared_ptr with out a specialisation of the template get_pointer<typename T> for std::shared_ptr (see: How to resolve conflict between boost::shared_ptr and using std::shared_ptr?).

    After switching to std::shared_ptr I then switched to std::bind, this time using the std::placeholders, (thanks richard) the example code now compiles and works correctly.

    In order to use std::bind with boost::asio make sure that std::shared_ptr and the std::placeholders are also used.

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

Sidebar

Related Questions

Hy there, I'm trying to adapt an existing code to boost::variant. The idea is
I'm currently trying to adapt my application to use the Compatibility Libraries for Android
I'm trying to create a dependent select form like this one on AjaxRay .
This code was established in a previous post. I'm trying to adapt it to
I am trying to adapt some (to me) very complicated code to work with
I'm trying to adapt this DES encrypting example to AES, so I made the
So I'm trying to adapt this Dropdown menu on Joomla the styles work great
I'm trying to adapt my code with json in google maps. I tried looking
I'm trying to get nHibernate to use second-level cache with a many-to-one relationship, however
I'm trying to adapt a jquery-ui codebase to use RequireJs, and I'm deploying it

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.