In any case, this is completely different code from what you had in your previous post. I already showed you what to use for your previous code.
What you showed me in the previous code did not work, it did not compile. I am trying to give a thorough complete minimal example, without the complexity of my own classes.
Now, have a look at the code you wrote:
const std::function
callback = std::bind(&tcp_server::handle_accept, this, new_connection, std::placeholders::_1); You are declaring a function that takes a tcp_connection::pointer and a const boost::system::error_code& as parameters -- that's two parameters. But you're only using one placeholder in the bind, which means that the second parameter doesn't go anywhere, which is probably not your intention.
Sigh. I know that code wouldn't work. That is my interpretation of what you
gave me. Now you are talking about two arguments and placeholders, but why
would I give it a place holder, when I am giving it the argument directly?
the tcp_connection::pointer argument is new_connection. The placeholder is
for the error code which I am not supplying directly. Either way, it still
fails to compile if you add a std::placeholders::_2 on the end.
Can we just get a compilable working example of the following method while
maintaining the use of the std::function variable? I don't want to bind
directly, I don't want to use lambda, I want to have an std::function
variable that I can pass to others. It's really a simple 6 line problem....
The following code still fails to compile:
void start_accept()
{
tcp_connection::pointer new_connection =
tcp_connection::create(acceptor_.get_io_service());
std::function